WebDesignerInTraining
-
Content Count
3 -
Joined
-
Last visited
Content Type
Profiles
Forums
Calendar
Posts posted by WebDesignerInTraining
-
-
I think it is all correct. I just can't figure out where to go to retrieve the uploaded pictures.
<?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*/
**modified by design1online.com 1/16/2005
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 = "[email protected]";
$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) - $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:[email protected]">[email protected]</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>
-
If I post PHP code, would someone be able to look at it & if it needs to be edited to help me? It was done for me & doesn't work yet. It is completely foreign to me. Also & more importantly would someone be able to walk me through step by step on setting it up & the retrieval process?
The main functions of the form include:
-The details of the form be sent to the email
-The upload(browse) button send the picture somewhere where I can access it & resize it to post on my site.
-A simultaneous redirect to another page in my site upon pushing the submit button
-I think there are some security features in there as well which is a bonus.
Thanks in advance
Php Or Html Help - Expert Needed
in Website Design & SEO Help
Posted
That is what I have been told. When I go to look for them, they never come through. As a matter of fact, the contents of the form never come through. Is there something else I should be doing? Keep in mind I don't know code.
Thanks