- This topic is empty.
-
AuthorPosts
-
September 22, 2010 at 11:20 am #30317j1300Member
I know that you guys must get a lot of these requests but this is my first contact form and ive literally been staring at this code for hours!
I tried using the form available here (after not being able to do another one)
Ive tried to add a dropdown box but am unable to get the email to contain the phone number and subject (chosen from the drop down box)
the html used is:
PHP in contactengine.php
$EmailFrom = "My website Enquiry";
$EmailTo = "[email protected]";
$Subject = Trim(stripslashes($_POST));
$Name = Trim(stripslashes($_POST));
$Tel = Trim(stripslashes($_POST));
$Email = Trim(stripslashes($_POST));
$Message = Trim(stripslashes($_POST));
// validation
$validationOK=true;
if (!$validationOK) {
print "";
exit;
}
// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "n";
$Body .= "Subject: ";
$Body .= $Subject;
$Body .= "n";
$Body .= "Phone: ";
$Body .= $Phone;
$Body .= "n";
$Body .= "Email: ";
$Body .= $Email;
$Body .= "n";
$Body .= "Message: ";
$Body .= $Message;
$Body .= "n";
// send email
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
// redirect to success page
if ($success){
print "";
}
else{
print "";
}
?>The emails I am getting are as below:
Name: Joe Bloggs
Subject:
Phone:
Email: [email protected]
Message: Test message……………………..
With no phone number or subject (from the drop down box). How can I fix this?Any help at all would be greatly appreciated!
Thanks in advanceSeptember 22, 2010 at 4:37 pm #79269ImpInaBoxMemberYour select tag for Subject is actually called ‘dropown’ not ‘Subject’. It will appear to your form processor as $_POST.
Change <select name=”dropdown”> to <select name=”Phone”>The $_POST field is being put into $Tel not $Phone.
Change $Tel = $_POST; to $Phone = $_POST;I would add too that you should probably validate the fields that your user can type into to check they don’t contain MIME codes aimed at hijacking your mailserver. Probably best to get the thing working first tho – worry about the rest later!
September 22, 2010 at 7:08 pm #79243j1300MemberThanks alot ImpInaBox!!
All up and working now :) will look into validating the text (the form that I tried before this one did it, so will take a look and try and understand)
Thanks again! its much appreciated
-
AuthorPosts
- The forum ‘Back End’ is closed to new topics and replies.