Simple Enquiry Form
I have a simple enquiry form i have on a html doc contact us page.
I need the form to send an email to the nominated email address all the information entered into the form once the submit button is hit.
The form i have in there now works fine but ONLY sends the comments section, not the name, number, email address of the person filling it out. I have a feeling that it is something small with the end of the coding in the PHP script where it tells the form which part of the form to email.
I think this bit is wrong, and i cannot figure out how it is meant to look.
else {
mail( "$webmaster_email", "Website Feedback Form Results",
$full_name, $contact_number, $comments, "From: $email_address" );
header( "Location: $thankyou_page" );
}
If I put it so that it says this only:
mail( "$webmaster_email", "Website Feedback Form Results",
$comments, "From: $email_address" );
it works fine, but only sends me the comments.
When I thought that adding the other values to the code that it would send me the 3 bits, it just doesnt work.
It goes to the thank you page but does not come through to my email address.
The HTML form code is as follows:
<form action="send_mail.php" method="post">
<table>
<tr>
<td>Full Name:</td>
<td>
<input type="text" name="full_name" value="" maxlength="100" />
</td>
</tr>
<tr>
<td>Contact Number:</td>
<td>
<input type="text" name="contact_number" value="" maxlength="100" />
</td>
</tr>
<tr>
<td>Email Adress:</td>
<td>
<input type="text" name="email_address" value="" maxlength="100" />
</td>
</tr>
<tr>
<td>Comments:</td>
<td>
<textarea rows="10" cols="50" name="comments"></textarea>
</td>
</tr>
<tr><td> </td>
<td>
<input type="submit" value="Submit" />
</td>
</tr>
</table>
</form>
and the PHP script is as follows:
<?php
$webmaster_email = "email@address.com";
$feedback_page = "index.html";
$error_page = "index_error.html";
$thankyou_page = "index_thanks.html";
$full_name = $_REQUEST['full_name'] ;
$contact_number = $_REQUEST['contact_number'] ;
$email_address = $_REQUEST['email_address'] ;
$comments = $_REQUEST['comments'] ;
function isInjected($str) {
$injections = array('(\n+)',
'(\r+)',
'(\t+)',
'(%0A+)',
'(%0D+)',
'(%08+)',
'(%09+)'
);
$inject = join('|', $injections);
$inject = "/$inject/i";
if(preg_match($inject,$str)) {
return true;
}
else {
return false;
}
}
if (!isset($_REQUEST['email_address'])) {
header( "Location: $feedback_page" );
}
elseif (empty($email_address) || empty($comments)) {
header( "Location: $error_page" );
}
elseif ( isInjected($email_address) ) {
header( "Location: $error_page" );
}
else {
mail( "$webmaster_email", "Website Feedback Form Results",
$full_name, $contact_number, $comments, "From: $email_address" );
header( "Location: $thankyou_page" );
}
?>
hopefully someone can help me get it working so that it emails me all the values of the form together.
If you even have a fresh new code that works better and is as easy to understand, that would be VERY helpful too!
All help appreciated greatly.
|