Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Contact Profiles with photos?
Old 11-20-2007, 08:54 AM Contact Profiles with photos?
Junior Talker

Posts: 1
Trades: 0
Hey guys pretty new to the forums here. I am fairly new with php and mysql.

I'll get right down to the point. I hope you guys can help me out I am really desperate.

I am making a contact profile database. I got that figured out by looking at a tutorial. But now I need to make it that each profile have it's own image. I have tried couple of things but failed so I really hope you guys can help me out on this.

When I tried it, I just added an upload field on the form and let it be uploaded to "LONGBLOB" on an "image" field on my database. But when I submit it, the image doesn't get uploaded.

When I manually uploaded the image to the entry, I did "<img src="<? $image ?>"> to display it in index.php, But it only came out as binary codes. So I am completely lost. Below is the coding for it atm, it's nothing fancy.

There are 4 files.

1. dbinfo.inc.php (login/db details)
PHP Code:
<?
$username
="****";
$password="****";
$database="test";
?>


2. add.html (The form to insert data)
PHP Code:
<form action="insert.php" method="post" enctype="multipart/form-data">
First Name: <input type="text" name="first"><br>
Last Name: <input type="text" name="last"><br>
Phone: <input type="text" name="phone"><br>
Mobile: <input type="text" name="mobile"><br>
Fax: <input type="text" name="fax"><br>
E-mail: <input type="text" name="email"><br>
Web: <input type="text" name="web"><br>
<
input type="Submit">
</
form


3. insert.php (the processor for add.html)
PHP Code:
<?
include("dbinfo.inc.php");

$first=$_POST['first'];
$last=$_POST['last'];
$phone=$_POST['phone'];
$mobile=$_POST['mobile'];
$fax=$_POST['fax'];
$email=$_POST['email'];
$web=$_POST['web'];

mysql_connect(localhost,$username,$password);
@
mysql_select_db($database) or die( "Unable to select database");

$query "INSERT INTO contacts VALUES ('','$first','$last','$phone','$mobile','$fax','$email','$web')";
mysql_query($query);

if(
$query)
{print( 
"Success!!!!!" );}
else
{print( 
"Failed!!!!!!" );}

mysql_close();
?>


4. index.php (To display them)
PHP Code:
<?
include("dbinfo.inc.php");
mysql_connect(localhost,$username,$password);
@
mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM contacts";
$result=mysql_query($query);

$num=mysql_numrows($result); 

mysql_close();

echo 
"<b><center>Database Output</center></b><br><br>";

?>
<table border="0" cellspacing="2" cellpadding="2">
<tr> 
<th><font face="Arial, Helvetica, sans-serif">Name</font></th>
<th><font face="Arial, Helvetica, sans-serif">Phone</font></th>
<th><font face="Arial, Helvetica, sans-serif">Mobile</font></th>
<th><font face="Arial, Helvetica, sans-serif">Fax</font></th>
<th><font face="Arial, Helvetica, sans-serif">E-mail</font></th>
<th><font face="Arial, Helvetica, sans-serif">Website</font></th>
</tr>

<?
$i
=0;
while (
$i $num) {
$first=mysql_result($result,$i,"first");
$last=mysql_result($result,$i,"last");
$phone=mysql_result($result,$i,"phone");
$mobile=mysql_result($result,$i,"mobile");
$fax=mysql_result($result,$i,"fax");
$email=mysql_result($result,$i,"email");
$web=mysql_result($result,$i,"web"); 
?>

<tr> 
<td><font face="Arial, Helvetica, sans-serif"><? echo "$first $last"?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><? echo "$phone"?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><? echo "$mobile"?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><? echo "$fax"?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><a href="mailto:<? echo "$email"?>">E-mail</a></font></td>
<td><font face="Arial, Helvetica, sans-serif"><a href="<? echo "$web"?>">Website</a></font></td>
</tr>
<?
++$i;

echo 
"</table>";


?>
That's it. Please help! You can ask me if you need anything else in order to help me

Last edited by Chinmi; 11-20-2007 at 10:06 AM..
Chinmi is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 11-20-2007, 08:57 AM Re: Contact Profiles with photos?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
moving to PHP
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to Contact Profiles with photos?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.10079 seconds with 12 queries