I have a story.php page that a user can click to read about different animals. When the user reads a story about a dog, the dog story is record ID of 4. I can pass this to the next page which is upload.php where a user can upload an image of their own dog for others to see. What I can't seem to do is pass the ID variable from this page. My upload.php page code is as follows.
<?PHP
include("function.php");
//The If and Switch direct people on the choices they make.
if ($option) {
switch ($option) {
case "upload":
require("header.php");
//This is your basic form
echo "<FORM METHOD=POST ACTION='upload.php?option=process' ENCTYPE='multipart/form-data'>\n
<B>*Your Name:</B><BR>\n
<INPUT TYPE=TEXT NAME='yourname' SIZE=50 MAXLENGTH=50><BR><BR>\n
<input type=hidden name='ID' value='[COLOR=Red][B]$ID[/B][/COLOR]'>\n
<B>*Email Address:</B> <SMALL>(Your Valid Email Address)</SMALL><BR>\n
<INPUT TYPE=TEXT NAME='email_address' SIZE='30' MAXLENGTH='50'><BR><BR>\n
<B>*Caption:</B><BR>\n
<INPUT TYPE=TEXT NAME='caption' SIZE=50 MAXLENGTH=50><BR><BR>\n
*<B>File:</B><BR><SMALL>(max file size 1 MB (1,024 kb) and .jpg or .jpeg file format only)</SMALL><BR>\n
<INPUT TYPE=FILE NAME='userfile' SIZE=50><BR><BR>\n
* <FONT COLOR='#FF0000'>Signify Required Fields</FONT><BR><BR>\n
<INPUT TYPE=SUBMIT NAME='SUBMIT' VALUE='Submit File'>\n
<BR><BR>Only hit Submit File once and wait for file to upload.\n
</FORM>\n";
require("footer.php");
break;
case "process":
//This checks to make sure all the required fields are filled out
if (($yourname) && ($email_address) && ($caption) && ($userfile)) {
//This checks to mack sure a file was specified to be uploaded
if ($userfile == "none") {
require("header.php");
echo "You neglected to specify a file please use the back button to fill in reqired info.<BR><BR>\n";
echo "If you have reached this page in error please <A HREF='upload.php'>Click Here</A>.\n";
require("footer.php");
exit;
}
//Checks to make sure the file size is > 0 and < 1 megs
if (($userfile_size == 0) || ($userfile_size > 1024000)) {
require("header.php");
echo "Your uploaded file is zero length or exceeds 1024k please use the back button to choose another file.<BR><BR>\n";
echo "If you have reached this page in error please <A HREF='upload.php'>Click Here</A>.\n";
require("footer.php");
exit;
}
//Trims Spaces off the strings
$yourname = trim($yourname);
$email_address = trim($email_address);
//Checks to see if the user entered a valid email address
email_validation($email_address);
//Copies file to specified location
if (copy($userfile, "photos/$userfile_name")) {
$userfile_location = "photos/";
//Deletes file in TMP directory
unlink($userfile);
//Add File info to database
add_file($yourname, $email_address, $caption, $userfile_location, $userfile_name, $ID);
} else {
require("header.php");
echo "Your file could not be copied.\n";
require("footer.php");
}
} else {
require("header.php");
echo "You neglected to fill out all the required info<BR> please use the back button to fill in reqired info.<BR><BR>\n";
echo "If you have reached this page in error please <A HREF='upload.php'>Click Here</A>.\n";
require("footer.php");
}
break;
case "confirm":
require("header.php");
echo "$name, your file was successfully uploaded!<BR><BR>\n";
echo "Thank you for your photo submission<BR><BR>\n";
echo "From the staff at <B>Lady's Funeral Home & Crematory.</B><BR><BR>\n";
echo "Back <A HREF='upload.php'>Upload</A> page.<BR><BR>\n";
require("footer.php");
break;
default:
require("header.php");
echo "Please go back and select another page this one may be down.<BR><BR>\n
If the page still does not come up please contact us so we can correct the error.<BR><BR>\n
If you have reached this page in error <A HREF='upload.php'>Click Here</A>.\n";
require("footer.php");
break;
}
} else {
require("header.php");
echo "Please fill out the form below for photo submissions.<BR>\n
Make sure that you photo has *.jpg or *.jpeg for a file extension<BR>\n
Also, please reduce your photos to limit your file size to less than<BR>\n
1.0 MB (1,024 kb), as this will help us keep the photos for a longer<BR>\n
period of time and will load faster.<BR><BR>\n
<A HREF='upload.php?option&ID=$ID'>Click Here</A> to submit a photo.<BR><BR>\n";
require("footer.php");
}
?>
The upload.php page does 3 things. it uploads, processes, & confirms the information from the user. I am sending this info to a mysql db. If I hard code an ID into my hidden ID seen in red above, it will make to the db. I just can't get this page to get the ID from the preceding URL and pass it to the db without hardcoding it in, which is useless.