Hi. I saw a post for a script request for an address book with photos, and figured I'd give it a shot at making one. I have come across one little glitch...
The form lets me add all the info and upload a photo with no problem. However, if I don't upload a photo, I want a default picture put in its place ( one that is already in the programs "photos" folder ). The db table has a field that holds the photos name, and the display page just links to the folder and the pic.
So basically, if there is no photo uploaded, I want the data "smile.gif" inserted into the field for the photo name. I've tried several if, and elseif, statements, to no avail. Any suggestions?
include("connect.php"); $conn = mysql_connect("localhost","$dbuser","$dbpass"); if (!$conn) die ("Could not connect MySQL"); mysql_select_db($dbname,$conn) or die ("Could not open database"); $query = "INSERT INTO addresses VALUES('','$first_name','$last_name','$home_phone','$cell_phone','$work_phone','$address','$filename')"; $result=mysql_query($query);
echo "Your new contact has been added"; }
This is just giving me a blank page when I don't upload a file ( probably because there is no $filename for the insert ? ), but works fine when I do upload one. I took the if statements out that I had been trying, since they weren't working, and plan to add filetype and size limits in the future.