Jump to content

jnrng2000

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

jnrng2000's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thank so much. It works. However i tried to query the datebase with the id to display the information. Once again the image position was marked with X .Looks like there is problem with the code below. <?php // Connects to your Database mysql_connect("localhost", "###", "###") or die(mysql_error()) ; mysql_select_db("####") or die(mysql_error()) ; //query the db $id= $_POST['id']; $query = "SELECT * FROM table WHERE id=$id"; $result = mysql_query($query)or die(mysql_error()); while($row = mysql_fetch_array($result)) { echo "<p>FORM NUMBER :62RRI/ <b>".$id."</b><br><br>"; echo "<img src=http://localhost/army/images/".$row['photo']."> <br>"; echo "<p>Name: <b>".$row['name']."</b><br>"; echo "<p>E-Mail: <b>".$row['email']."</b><br>"; echo "<p>Phone Number: <b>".$row['phone']."</b><p>"; } ?>
  2. The image file is suppose to be generated from what the visitors to the site uploaded and display their information when the file is uploaded. I made a little modification on the code. Still having problem. Some images displayed while some didnt. Here is the code.Thanks <?php //This is the directory where images will be saved $ran = rand () ; $ran2 = $ran."."; $target = "images/"; $target = $target .$ran2. basename( $_FILES['photo']['name']); $ok=1; //This gets all the other information from the form $name=$_POST['name']; $email=$_POST['email']; $phone=$_POST['phone']; $pic=$ran2.($_FILES['photo']['name']); $pic= $_POST['photo']; // Connects to your Database mysql_connect("localhost", "###", "###") or die(mysql_error()) ; mysql_select_db("root") or die(mysql_error()) ; //Writes the information to the database mysql_query("INSERT INTO `table` (`name`, `email`,`phone`,`photo`) VALUES ('$name', '$email', '$phone', '$photo')") ; $id= mysql_insert_id(); //This is our size condition if ($uploaded_size > 35000) { echo "Your file is too large.<br>"; $ok=0; } //This is our limit file type condition if ($uploaded_type =="text/php") { echo "No PHP files<br>"; $ok=0; } //Here we check that $ok was not set to 0 by an error if ($ok==0) { Echo "Sorry your file was not uploaded"; } //If everything is ok we try to upload it else //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['photo']['name']). " has been uploaded, and your information has been added to the directory"; echo " Your Registration Form Number is . $id ";} else { //Gives and error if its not echo "Sorry, there was a problem uploading your file.";} $query = "SELECT * FROM table WHERE id=$id"; $result = mysql_query($query)or die(mysql_error()); while($row = mysql_fetch_array($result)) { echo "<p>FORM NUMBER :62RRI/ <b>".$id."</b><br><br>"; echo "<img src=http://localhost/army/$target".$row['photo']."> <br>"; echo "<p>Name: <b>".$row['name']."</b><br>"; echo "<p>E-Mail: <b>".$row['email']."</b><br>"; echo "<p>Phone Number: <b>".$row['phone']."</b><p>"; echo "<p>Your Photo: <b>".$row['photo']."</b><p>"; } ?> [code] [/code]
  3. I tried to upload and display an image from a particular row in mysql. The upload was ok cause the image file was sent to the folder. However, the image would not display instead X was diplayed at the image position. Other informations were displayed correctly.Could it be that my path was not correctly defined. Could someone help me .Thanks in anticipation. Here is the code. <?php //This is the directory where images will be saved $ran = rand () ; $ran2 = $ran."."; $target = "images/"; $target = $target .$ran2. basename( $_FILES['photo']['name']); $ok=1; //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 mysql_connect("localhost", "###", "####") or die(mysql_error()) ; mysql_select_db("####") or die(mysql_error()) ; //Writes the information to the database mysql_query("INSERT INTO `table` (`name`, `email`,`phone`,`photo`) VALUES ('$name', '$email', '$phone', '$pic')") ; $id= mysql_insert_id(); //This is our size condition if ($uploaded_size > 35000) { echo "Your file is too large.<br>"; $ok=0; } //This is our limit file type condition if ($uploaded_type =="text/php") { echo "No PHP files<br>"; $ok=0; } //Here we check that $ok was not set to 0 by an error if ($ok==0) { Echo "Sorry your file was not uploaded"; } //If everything is ok we try to upload it else //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['photo']['name']). " has been uploaded, and your information has been added to the directory"; echo " Your Registration Form Number is . $id ";} else { //Gives and error if its not echo "Sorry, there was a problem uploading your file.";} $query = "SELECT * FROM table WHERE id=$id"; $result = mysql_query($query)or die(mysql_error()); while($row = mysql_fetch_array($result)) { echo "<p>FORM NUMBER :62RRI/ <b>".$id."</b><br><br>"; echo "<img src=http://localhost/army/$target".$row['photo']."> <br>"or die(mysql_error()); echo "<p>Name: <b>".$row['name']."</b><br>"; echo "<p>E-Mail: <b>".$row['email']."</b><br>"; echo "<p>Phone Number: <b>".$row['phone']."</b><p>"; echo "<p>Your Photo: <b>".$row['photo']."</b><p>"; } ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.