sandbudd Posted June 30, 2008 Share Posted June 30, 2008 it saves it to a file then displays the image in the results page...question is how do I make it a link instead of displaying the image itself? add.php <?php //This is the directory where images will be saved $target = "try/images/"; $target = $target . basename( $_FILES['photo']['name']); //This gets all the other information from the form $name=$_POST['name']; $email=$_POST['email']; $phone=$_POST['phone']; $pic=($_FILES['photo']['name']); // Connects to your Database $db_host = ''; $db_user = ''; $db_pwd = ''; $database = ''; $table = ''; ini_set('error_reporting',E_ALL); if (!mysql_connect($db_host, $db_user, $db_pwd)) die("Can't connect to database"); if (!mysql_select_db($database)) die("Can't select database"); //Writes the information to the database mysql_query("INSERT INTO `employees` VALUES ('$name', '$email', '$phone', '$pic')") ; //Writes the photo to the server if(move_uploaded_file($_FILES['photo']['tmp_name'], $target)) { //Tells you if its all ok echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the directory"; } else { //Gives and error if its not echo "Sorry, there was a problem uploading your file."; } ?> retrieve.php <?php // Connects to your Database $db_host = ''; $db_user = ''; $db_pwd = ''; $database = ''; $table = ''; ini_set('error_reporting',E_ALL); if (!mysql_connect($db_host, $db_user, $db_pwd)) die("Can't connect to database"); if (!mysql_select_db($database)) die("Can't select database"); //Retrieves data from MySQL $data = mysql_query("SELECT * FROM employees") or die(mysql_error()); //Puts it into an array while($info = mysql_fetch_array( $data )) { //Outputs the image and other data Echo "<img src=http://www.sandbudd.com/try/images/".$info['photo'] ."> <br>"; Echo "<b>Name:</b> ".$info['name'] . "<br> "; Echo "<b>Email:</b> ".$info['email'] . " <br>"; Echo "<b>Phone:</b> ".$info['phone'] . " <hr>"; } ?> Link to comment https://forums.phpfreaks.com/topic/112541-solved-saves-to-file-and-the-display-page-displays/ Share on other sites More sharing options...
sandbudd Posted June 30, 2008 Author Share Posted June 30, 2008 got it with this //Outputs the image and other data Echo "<a href=http://www.sandbudd.com/try/images/".$info['photo'] ."> file <br></a>"; Echo "<b>Name:</b> ".$info['name'] . "<br> "; Echo "<b>Email:</b> ".$info['email'] . " <br>"; Echo "<b>Phone:</b> ".$info['phone'] . " <hr>"; } Link to comment https://forums.phpfreaks.com/topic/112541-solved-saves-to-file-and-the-display-page-displays/#findComment-577906 Share on other sites More sharing options...
MasterACE14 Posted June 30, 2008 Share Posted June 30, 2008 nice. Link to comment https://forums.phpfreaks.com/topic/112541-solved-saves-to-file-and-the-display-page-displays/#findComment-577907 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.