|
Not posting to MySQL database...
Hum. I've been messing around with my data submitting code trying implement an image upload, and now I've done tangled up my code. The form loads up, and I recieve my Echo stating that I've posted the form data with the image to the database, but nothing is actually posted. I'm pretty sure the problem is in my PHP code somewhere. Can anyone help me out? Keep in mind I'm still relatively new at all of this! Thanks...
(I've edited my posted code a few times. It's just the image submitting I'm having trouble with, now)
php Code:
Original
- php Code |
|
|
|
<?php if(isset($_POST['submit'])) { $first_name=$_POST[first_name]; $last_name=$_POST[last_name]; $hometown=$_POST[hometown]; $age=$_POST[age]; $major=$_POST[major]; $anything=$_POST[anything]; $id=$_POST[id]; $image_types = Array ("image/bmp", "image/jpeg", "image/pjpeg", "image/gif", "image/x-png"); $file_name = $_FILES["userfile"]["name"]; $file_size = $_FILES["userfile"]["size"]; $file_type = $_FILES["userfile"]["type"]; $sql = "INSERT INTO Freshmen (first_name,last_name,hometown,age,major,anything, image_name,image_type,image_size,image_date) "; $sql.= "VALUES ("; $sql.= "'{$first_name}', '{$last_name}', '{$hometown}', '{$age}', '{$major}', '{$anything}', '{$file_type}', '{$userfile}', '{$file_size}', '{$file_name}', NOW())"; Header("Location:". $_SERVER["PHP_SELF"]); echo "Thank you! Information entered with picture.n"; } else { $sql = "INSERT INTO Freshmen (first_name,last_name,hometown,age,major,anything) VALUES ('$first_name', '$last_name', '$hometown', '$age', '$major', '$anything')"; echo "Thank you! Information entered without picture.n"; } } else { ?> <form method="post" action="<?php echo $PHP_SELF?>" enctype="multipart/form-data"> First name:<input type="Text" name="first_name"><br> Last name:<input type="Text" name="last_name"><br> Hometown:<input type="Text" name="hometown"><br> Age:<input type="Text" name="age"><br> Major:<input type="Text" name="major"><br> Anything? <input type="Text" name="anything"><br> Image of yourself II <input type="file" name="userfile" size="40"><br> <input type="Submit" name="submit" value=" Enter information"></form> <?php } ?>
Thanks again...
Signed,
Weary in Washington!
|