Hello,
I am quite new with php and am doing my girlfriends website where she needs a get a quote page. I have set up teh forms and the php and though tit was ok. The problem is that it does not send the quote to the selected email addfress. I am not sure where i am going wrong. I have been trying to find help but am not having any luck and was wondering if anyone can look at my code with any suggestions please?
<?
// the email address
$youremail = 'amiee.rodgers@ntlworld.com';
// web site title
$websitetitle = 'alrwritingservices.co.uk';
// thank you page
$thankyoupage = 'thankyou.php';
// Send notification to sender
$sendnotification = false;
$contact_form_action = $_SERVER['PHP_SELF'];
if ((isset($_POST["sendcontact"])) && ($_POST["sendcontact"] == "contactsent")) {
$contacter_form_error = array();
if (empty($_POST['contact_name'])){
$contacter_form_error[] = 'please insert your name';
}
if (empty($_POST['contact_email'])){
$contacter_form_error[] = 'please insert your email address';
}
if (empty($_POST['contact_comment'])){
$contacter_form_error[] = 'please insert your comment';
}
else {
$contact_name = stripslashes($_POST['contact_name']);
$contact_email = stripslashes($_POST['contact_email']);
$contact_comment = $contact_name." said:\n \"".stripslashes($_POST['contact_comment'])."\"\n";
$subjectline = "$websitetitle | A Message From $contact_name";
if(!empty($_POST['best_time'])) {
$contact_comment .= '(Best time to contact is: '.stripslashes($_POST['best_time']).')'."\n";
}
if(!empty($_POST['contact_phone'])) {
$contact_comment .= '(Phone number is: '.stripslashes($_POST['contact_phone']).')';
}
mail($youremail, $subjectline, $contact_comment, "From: $contact_email");
if($sendnotification == true) {
$notification_message = "Thank you for contacting $websitetitle, $contact_name. We have received your email and will be in touch shortly";
$notification_subject = "Thanks for your message to $websitetitle.";
mail($contact_email, $notification_subject, $notification_message, "From: $youremail");
}
header("Location:$thankyoupage");
}
}
?>
<?
// Print form field errors if present
if (count($contacter_form_error)>0){
print '<p id="bottom"><strong>Some details are missing</strong></p>'."\n";
print '<ul>'."\n";
foreach($contacter_form_error as $form_err) {
print "<li class=\"error\">$form_err</li>\n";
}
print '</ul>'."\n";
}
?>
The html used is :-
<form method="post" id="contactform" action="<? print $contact_form_action; ?>">
<div>
<p>All required fields are denoted by an asterix (<span class="required"></span>).</p>
<fieldset>
<legend>Your Details</legend>
<label for="contact_name">Your Name <span class="required"></span></label>
<br />
<input type="text" id="contact_name" name="contact_name" size="30" value="<? print $contact_name; ?>" />
<br />
<label for="contact_email">Your Email <span class="required"></span></label>
<br />
<input type="text" id="contact_email" name="contact_email" size="30" value="<? print $contact_email; ?>" />
<br />
<label for="project_type">Type of project</label>
<br />
<input type="text" id="project_type" name="project_type" size="30" value="<? print $_POST['project_type']; ?>" />
<br />
<label for="project_length">how many words </label>
<br />
<select id="project_length" name="project_length">
<option value="100300">100-300</option>
<option value="300600">300-600</option>
<option value="6001100">600-1100</option>
<option value="1200">1200+</option>
</select>
</fieldset>
<fieldset>
<legend></legend>
<p>
<label for="label">Any other detail (type n/a if none) <span class="required"></span></label>
<label for="contact_comment"></label>
<br />
<textarea name="contact_comment" cols="48" rows="10" id="contact_comment"><? print $contact_comment; ?></textarea>
</p>
</fieldset>
<input type="hidden" name="sendcontact" value="contactsent" />
<input type="submit" value="Send Email" />
</div>
</form>
Any help would be very much appreciated, thanks