Could someone help me (walk me through) what is wrong or what is going wrong with my form.
Background Info:
I built a very large site using Serif Webplus 9.0 (drag & drop).
I originally used Frontpage for my form(s) but was told to drop Frontpage for numerous reasons.
So now, I am attempting to make a new form using Dreamweaver or NVU.
The major functions of the form is supposed to:
1. Send the filled out details to an email address. (photosaroundtown@lifearoundtown.com)
2. Send an uploaded picture file somewhere where I can access it for resizing & future posting.
3. Simultaneously redirect to another page in my site upon pushing the submit button. (www.lifearoundtown.com/thankyoupage.html)
4. Have the banner that I created actually show up at the top of the form to match the site.
Other notes:
I have been told by the creator that the code is correct. It is possible that I am not doing something else that needs to be done? It might be something little that most people take for granted & do all the time.
Any help you could shed on this would be greatly appreciated. Please keep in mind that I don't know code at all & need to be slowly walked through the process.
Thanks in advance
Here is the code:
<?php
/ IMPORTANT NOTICE: Make sure that the <?php tag (above) is the first line, there cannot
be anything above it, not even a blank line. If there is you will get "HEADERS already
sent error messages
**Script modified by Gail Kasey 14/01/06/
if (isset($POST['submitted']))
{
$errors = array(); // Initialize error array.
if ($fundraiserCode != "") //Modified the re-direction code
{
$url = 'http://' . $SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']);
// Check for a trailing slash.
if ((substr($url, -1) == '/') OR (substr($url, -1) == '\') )
{
$url = substr ($url, 0, -1); // Chop off the slash.
}
$url .= '/thankyoupage.html'; // Add the page.
header("Location: $url");
}
// Check for a first name.
if (empty($POST['firstName'])) {
$errors[] = 'You forgot to enter your first name.';
} else {
$firstname = trim($POST['firstName']);
}
// Check for a last name.
if (empty($POST['lastName'])) {
$errors[] = 'You forgot to enter your last name.';
} else {
$lastname = trim($POST['lastName']);
}
//Check for name of town
if (empty($POST['townPictures'])) {
$errors[] = 'Please enter the name of the town.';
} else {
$townPictures = trim($POST['townPictures']);
}
//Check for State
if (empty($POST['State'])) {
$errors[] = 'Please enter your State.';
} else {
$State = trim($POST['State']);
}
//Check for subject
if (empty($POST['Subject'])) {
$errors[] = 'Please enter a unique name for your pic.';
} else {
$pictureSubject = trim($POST['Subject']);
}
//Validating Email format
if (!eregi('[[:alnum:]][a-z0-9.-]*@[a-z0-9.-]+.[a-z]{2,4}$', trim($POST['email'])))
{$errors[] = 'The email you entered seems to be invalid.';}
//Redirected to thank you page if box is checked
if ($POST['actualPicturesEmail'] == 'YES') {
$url = 'http://' . $SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']);
// Check for a trailing slash.
if ((substr($url, -1) == '/') OR (substr($url, -1) == '\') )
{
$url = substr ($url, 0, -1); // Chop off the slash.
}
$url .= '/thankyoupage.html'; // Add the page.
header("Location: $url");
}
//If this box is checked it will look for a valid image to be uploaded
if ($POST['actualPicturesForm'] == 'YES') {
if (isset($FILES['upload']))
{
// Validate the type. Should be jpeg, jpg, or gif.
$allowed = array ('image/gif', 'image/jpeg', 'image/jpg', 'image/pjpeg');
if (in_array($_FILES['upload']['type'], $allowed))
{
// Move the file over. If successfull the user will be redirected to thank you page
if (move_uploaded_file($FILES['upload']['tmp_name'], "uploads/{$FILES['upload']['name']}"))
{
$url = 'http://' . $SERVER['HTTP_HOST'] . dirname($SERVER['PHP_SELF']);
// Check for a trailing slash.
if ((substr($url, -1) == '/') OR (substr($url, -1) == '\') )
{
$url = substr ($url, 0, -1); // Chop off the slash.
}
$url .= '/thankyoupage.html'; // Add the page.
header("Location: $url");
}
else
{ // Couldn't move the file over.
echo '<p><font color="red">The file could not be uploaded because: </b>';
// Print a message based upon the error.
switch ($_FILES['upload']['error']) {
case 1:
print 'The file exceeds the upload_max_filesize setting in php.ini.';
break;
case 2:
print 'The file exceeds the MAX_FILE_SIZE setting in the HTML form.';
break;
case 3:
print 'The file was only partially uploaded.';
break;
case 4:
print 'No file was uploaded.';
break;
case 6:
print 'No temporary folder was available.';
break;
default:
print 'A system error occurred.';
break;
} // End of switch.
print '</b></font></p>';
} // End of move... IF.
} else { // Invalid type.
echo '<p><font color="red">Please upload a JPEG or GIF image.</font></p>';
unlink ($_FILES['upload']['tmp_name']); // Delete the file.
}
} //End checkbox if statement
} //End of uploading image if statement
if (empty($errors)) { // If everything's OK.
// This is the email the support forum is sent to... change it to what you want
$submitemail = "PhotosAroundTown@LifeAroundTown.com";
$subject = "Email from Form";
$title = "Form Submission";
$fundraiserCode = trim($POST['fundraiserCode']);
$email = trim($POST['email']);
$message = "Title: {$title}\r\n";
$message .= "First Name: {$firstname}\r\n";
$message .= "Last Name: {$lastname}\r\n"; //Fixed varaible spelling error
$message .= "City: {$townPictures} \r\n";
$message .= "State: {$State} \r\n";
$message .= "Subject: {$pictureSubject} \r\n"; // Fixed variable spelling error
$message .= "Fundraiser code: {$fundraiserCode} \r\n";
$message .= "Actual Pictures in Email: {$POST['actualPicturesEmail']} \r\n";
$message .= "Actual Pictures with Form: {$POST['actualPicturesForm']} \r\n";
$message .= "Actual Pictures Printed: {$_POST['actualPicturesPrinted']} \r\n";
$mailHeader = "From: {$email}\r\n";
$mailHeader .= "Reply-To: {$email}\r\n";
$mailHeader .= "X-Mailer: PHP/" . phpversion();
mail($submitemail, $subject, $message, $mailHeader);
$mailHeader = "From: {$submitemail}\r\n";
$mailHeader .= "Reply-To: {$submitemail}\r\n";
$mailHeader .= "X-Mailer: PHP/" . phpversion();
$clientmessage = "Thank you {$firstname} for Submitting your pictures. This is an automated E-mail response, please do not respond to it.\r\n\n" . $message; //This is the message that will be sent to the User
mail($email, $subject, $clientmessage, $mailHeader);
} // End of Email
else
{
echo '<h1 id="mainhead">Error!</h1>
<p class="error">The following error(s) occurred: foreach($errors as $msg)
{
echo " - $msg }
echo '</p><p>Please try again</p><p> }
}// End of the submitted conditional.
?>
<!--Start of HTML section-->
<html>
<head>
<title>Photos Around Town Form</title>
</head>
<body link="blue" vlink="purple" alink="red">
<!--Aussie Girl: I've taken this image out of the form tags, it wont work because
of the name, if it's suppose to be the background for the form try doing a search
for background images in forms if it's a banner leave it has I have changed to and upload the image into the same folder has this script or change the img scr path-->
<img src="backgroundforwebsite26mv.jpg" width="800" height="150" border="0">
<div align="center"><h2>Photos Around Town Form</h2></div>
<form enctype="multipart/form-data" name="Photos Around Town Form" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<fieldset>The information below will be used solely for milling, organizational needs, and if contact is required.
<p>First Name: <input type="text" name="firstName">
Last Name: <input type="text" name="lastName"></p>
<p>Email Address: <input type="text" name="email" size="57"></p>
<p>Town picture(s) is/are being placed <input type="text" name="townPictures" > State <input type="text" name="State" size="9"></p>
<p>Picture Subject <input type="text" name="Subject"> Fundraiser Participant Code: <input type="text" name="fundraiserCode"></p>
<p>(For organizational purposes, please give us a unique name for your picture)</p>
<p>Please check this box <input type="checkbox" name="actualPicturesEmail" value="YES">if you are sending the actual picture(s) for this form via <u>email</u>.</p>
<p>Our email is:<a href="mailto😛hotosAroundTown@LifeAroundTown.com">PhotosAroundTown@LifeAroundTown.com</a></p>
<p>Please check this box <input type="checkbox" name="actualPicturesForm" value="YES">if you are sending the actual picture(s) attached with <u>this form</u>.
<input type="file" name="upload" size="61"></p>
<input type="hidden" name="MAX_FILE_SIZE" value="524288">
<p>Please check this box <input type="checkbox" name="actualPicturesPrinted" value="YES">if you are enclosing the actual picture(s) with a printed copy of this form. You are also initialing here showing that you understand that hard copies of pictures that need to be scanned in, may lose some quality.</p>
<div align="center"><input type="submit" name="Submit" value="Submit Form">
<input type="reset" name="reset" value="Reset Form"></div>
<input type="hidden" name="submitted" value="YES" />
</fieldset>
</form>
Life Around TownAttn: Photos Around Town Dept.PO Box 171Marlton NJ 08053<p style="line-height:100%; margin-top:0; margin-bottom:0;"> </p>
</body>
</html>