Forum Moderators: coopster
<form name="form1" method="post" action="output.php" enctype="multipart/form-data">
<input name="Name" id="Name" value="" size="20" class="fieldstyle" type="text"><input name="email" id="email" size="20" maxlength="100" class="fieldstyle" type="text">
<input name="Home_Phone" id="Home_Phone" value="" size="20" class="fieldstyle" type="text">
<Moderator's NOTE: more form fields here ...>
<input name="Submit" value="Submit" type="submit">
</form>
?php
// Receiving variables
$Name = addslashes($_POST['Name']);
$email = addslashes($_POST['email']);
$Home_Phone = addslashes($_POST['Home_Phone']);
$Mobile_Phone = addslashes($_POST['Mobile_Phone']);
$Mailing_Address = addslashes($_POST['Mailing_Address']);
$City = addslashes($_POST['City']);
$State = addslashes($_POST['State']);
$Post_Code = addslashes($_POST['Post_Code']);
$Bath_Option = addslashes($_POST['Bath_Option']);
$Type_of_Listing = addslashes($_POST['Type_of_Listing']);
$Rooms = addslashes($_POST['Rooms']);
$Covered_Parking = addslashes($_POST['Covered_Parking']);
$What_Type = addslashes($_POST['What_Type']);
$Features = addslashes($_POST['Features']);
$Price_Selling = addslashes($_POST['Price_Selling']);
$Price_Negotiable = addslashes($_POST['Price_Negotiable']);
$Pet_Friendly= addslashes($_POST['Pet_Friendly']);
$Comments = addslashes($_POST['Comments']);
if(isset($_FILES['picture1']['tmp_name']))
{
$tmp_name1 = $_FILES["picture1"]["tmp_name"];
$name1 = str_replace(' ', '_', $Name.'_'.$_FILES["picture1"]["name"]);
if(!move_uploaded_file($tmp_name1, "homesales/$name1"))
{
$error1 = 'Could not move file 1';
}
}
if(isset($_FILES['picture2']['tmp_name']))
{
$tmp_name2 = $_FILES["picture2"]["tmp_name"];
$name2 = str_replace(' ', '_', $Name.'_'.$_FILES["picture2"]["name"]);
if(!move_uploaded_file($tmp_name2, "homesales/$name2"))
{
$error2 = 'Could not move file 2';
}
}
if(isset($_FILES['picture3']['tmp_name']))
{
$tmp_name3 = $_FILES["picture3"]["tmp_name"];
$name3 = str_replace(' ', '_', $Name.'_'.$_FILES["picture3"]["name"]);
if(!move_uploaded_file($tmp_name3, "homesales/$name3"))
{
$error3 = 'Could not move file 3';
}
if(isset($_FILES['picture4']['tmp_name']))
{
$tmp_name4 = $_FILES["picture4"]["tmp_name"];
$name3 = str_replace(' ', '_', $Name.'_'.$_FILES["picture4"]["name"]);
if(!move_uploaded_file($tmp_name4, "homesales/$name4"))
{
$error4 = 'Could not move file 4';
}
if(isset($_FILES['picture5']['tmp_name']))
{
$tmp_name5 = $_FILES["picture5"]["tmp_name"];
$name3 = str_replace(' ', '_', $Name.'_'.$_FILES["picture5"]["name"]);
if(!move_uploaded_file($tmp_name5, "homesales/$name5"))
{
$error5 = 'Could not move file 5';
}
if(isset($_FILES['picture6']['tmp_name']))
{
$tmp_name6 = $_FILES["picture6"]["tmp_name"];
$name6 = str_replace(' ', '_', $Name.'_'.$_FILES["picture6"]["name"]);
if(!move_uploaded_file($tmp_name6, "homesales/$name6"))
{
$error6 = 'Could not move file 6';
}
}
// Validation
if (! ereg('[A-Za-z0-9_-]+\@[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+', $email))
{
header("Location: error.html");
exit;
}
//Sending Email to form owner
# Email to Owner
$pfw_header = "From: $email";
$pfw_subject = "Home Sale Advert Form";
// Change to your email address.........
$pfw_email_to = "webmaster@example.com";
//......................................
$pfw_message = "Name: $Name\n"
. "email: $email\n"
. "Home_Phone: $Home_Phone\n"
. "Mobile_Phone: $Mobile_Phone\n"
. "Mailing_Address: $Mailing_Address\n"
. "City: $City\n"
. "State: $State\n"
. "Post_Code: $Post_Code\n"
. "Bath_Option: $Bath_Option\n"
. "Type_of_Listing: $Type_of_Listing\n"
. "Rooms: $Rooms\n"
. "Covered_Parking: $Covered_Parking\n"
. "What_Type: $What_Type\n"
. "Features: $Features\n"
. "Price_Selling: $Price_Selling\n"
. "Price_Negotiable: $Price_Negotiable\n"
. "Pet_Friendly: $Pet_Friendly\n"
. "Comments: $Comments\n"
. "Image 1: $name1\n"
. "Image 2: $name2\n"
. "Image 3: $name3\n"
. "Image 4: $name4\n"
. "Image 5: $name5\n"
. "Image 6: $name6\n"
. "\n";
mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ;
//Sending auto respond Email to user
# Email to Owner
// Change to your email address.........
$pfw_header = "From: webmaster@arpra.org.au";
//......................................
$pfw_subject = "Confirmation Home Sale Advert Auto - Response";
$pfw_message = "Name: $Name\n"
. "email: $email\n"
. "Home_Phone: $Home_Phone\n"
. "Mobile_Phone: $Mobile_Phone\n"
. "Mailing_Address: $Mailing_Address\n"
. "City: $City\n"
. "State: $State\n"
. "Post_Code: $Post_Code\n"
. "Bath_Option: $Bath_Option\n"
. "Type_of_Listing: $Type_of_Listing\n"
. "Rooms: $Rooms\n"
. "Covered_Parking: $Covered_Parking\n"
. "What_Type: $What_Type\n"
. "Features: $Features\n"
. "Price_Selling: $Price_Selling\n"
. "Price_Negotiable: $Price_Negotiable\n"
. "Pet_Friendly: $Pet_Friendly\n"
. "Comments: $Comments\n"
. "\n";
mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ;
header("Location: thank_you.html");
?> [edited by: coopster at 3:01 pm (utc) on Sep 8, 2011]
[edit reason] showing relevant portion of form [/edit]