I am currently in a class for PHP and MYSQL. My web host is GoDaddy.com (GD) if that helps any, but I am using the most current version of Dreamweaver to write my code and upload it to my website.
The form below is part of the book’s course form. All the information in the form uploads into my database, including the ‘image’ name. However, the actual file (used in conjunction with the input type=“file” id=“image” name=“image”/> part of the form) does not upload or transfer into its final folder position, which is named ‘images’ in the same directory that my ‘index.php’ file resides on my account.
I have tried over a dozen different implementations, even going so far to have an external .php file to handle the image section, to no avail. Each time, the form outputs and uploads successfully minus the image (which gets the ‘else’ response of “Error with Image”. There are no syntax errors, and I have run through it in terms of how it executes, and I do not find a reason as to why it would not execute.
I have contacted GD support and they were not really helpful (even saying that it was better if I could write my code on Linux). In the end they told me what I already knew (to some degree) and that is with my code (somewhere). However, I am unaware as to where exactly the problem is, as I have followed the book instructions.
Any and all assistance is greatly appreciated.
(Note: all information related to my actually database, password etc has been removed due to security concerns)
-----------START OF PHP------------------
Aliens Abducted Me - Report an AbductionAliens Abducted Me - Report an Abduction
<?php define('GW_UPLOADPATH', 'images/'); if (isset($_POST['submit'])){ $first_name = $_POST['firstname']; $last_name = $_POST['lastname']; $email = $_POST['email']; $when_it_happened = $_POST['whenithappened']; $how_long = $_POST['howlong']; $how_many = $_POST['howmany']; $alien_description = $_POST['aliendescription']; $what_they_did = $_POST['whattheydid']; $fang_spotted = $_POST['fangspotted']; $other = $_POST['other']; $image = $_FILES['image']['name']; $image_type = $_FILES['image']['type']; $image_size = $_FILES['image']['size']; $image_temp = $_FILES['image']['tmp_name']; $image_error = $_FILES['image']['error']; $output_form = false; if (empty($first_name) && empty($last_name) && empty($email)) { echo 'You MUST enter your First Name.'; echo 'You MUST enter your Last Name.
'; echo 'You MUST enter your Email Address.
'; $output_form = true; } if (empty($first_name) && (!empty($last_name)) && empty($email)) { echo 'You MUST enter your First Name.
'; echo 'You MUST enter your Email Address.
'; $output_form = true; } if (empty($first_name) && empty($last_name) && (!empty($email))) { echo 'You MUST enter your First Name.
'; echo 'You MUST enter your Last Name.
'; $output_form = true; } if (empty($first_name) && (!empty($last_name)) && (!empty($email))) { echo 'You MUST enter your First Name.
'; $output_form = true; } if ((!empty($first_name)) && empty($last_name) && empty($email)) { echo 'You MUST enter your Last Name.
'; echo 'You MUST enter your Email Address.
'; $output_form = true; } if ((!empty($first_name)) && empty($last_name) && (!empty($email))) { echo 'You MUST enter your Last Name.
'; $output_form = true; } if ((!empty($first_name)) && (!empty($last_name)) && empty($email)) { echo 'You MUST enter your Email Address.
'; $output_form = true; } } else { $output_form = true; } if ($output_form) { ?>
Share your story of alien abduction:
Other Abductee StoriesFirst name:
Last name:
What is your email address?
When did it happen?
How long were you gone?
How many did you see?
Describe them:
What did they do to you?
Have you seen my dog Fang?
Yes <input id=“fangspotted” name=“fangspotted” type=“radio” value=“Yes” <?php if (isset($_POST['fangspotted']) && $_POST['fangspotted'] == "Yes") echo 'checked="checked"';?>>
No <input id=“fangspotted” name=“fangspotted” type=“radio” value=“No” <?php if (isset($_POST['fangspotted']) && $_POST['fangspotted'] == "No") echo 'checked="checked"';?>>
Anything else you want to add?
<?php echo $_POST['other']; ?>
Evidence:
'; echo 'You were abducted ' . $when_it_happened; echo ' and were gone for ' . $how_long . '
'; echo 'Number of aliens: ' . $how_many . '
'; echo 'Describe them: ' . $alien_description . '
'; echo 'The aliens did this: ' . $what_they_did . '
'; echo 'Was Fang there? ' . $fang_spotted . '
'; echo 'Other comments: ' . $other . '
'; echo 'Your email address is ' . $email . '
'; if(is_file($row['image']) && filesize($row['image'])>0) { $target = GW_UPLOADPATH . $image; if (move_uploaded_file($_FILES['image']['tmp_name'], $target)) { $dbc = mysqli_connect('**.**.***.**','****','****','****') or die ('Error connecting to MySQL server.'); $query = "INSERT INTO **** VALUES (0, '$first_name', '$last_name', '$when_it_happened', '$how_long', '$how_many', " . "'$alien_description', '$what_they_did', '$fang_spotted', '$other', '$email', '$image')"; mysqli_close($dbc, $query); } echo '
'; } } ?>
--------------------END of PHP-----------------------