Hi guys,
Trying to get a PHP form mailer to work right, pretty much just a simple contact gatherer... I've gotten the code from someone else who doesn't provide support for any of it, and I've gotten it all to work except for the form actually sending me the email... When clicking the submit button, it redirects properly to the "Thanks for contacting us" page, but even now an hour later, still no email. Here is all of the code for the PHP on the page:
<?
#############################################################
// Contacter V 0.1 | by Gordon Mackay | http://gordonmac.com/
#############################################################
#############################################################
// set your own preferences here
#############################################################
// Your email address
$youremail = 'matthewlivengood@yahoo.com';
// Your web site title (John Doe's Site)
$websitetitle = 'LIFT Investor Site';
// Path to "thanks for the message" page
$thankyoupage = 'thankyou.php';
// Send notification to sender (use false if not required)
$sendnotification = false;
#############################################################
// Do not edit below this
#############################################################
$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_phone'])){
$contacter_form_error[] = 'please insert your phone number';
}
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");
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Test Page 2</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Simple…</title>
<!--
!!DO NOT DELETE THIS COMMENT!!
// "Simple..." v1.0 (12th December 2007) (C) Gordon Mackay. //
- Website: http://gordonmac.com/
- Contact me: http://gordonmac.com/contact/
- Free stuff: http://gordonmac.com/downloads/
-->
<link href="layout.css" rel="stylesheet" type="text/css" media="screen" />
<link href="basic_styles.css" rel="stylesheet" type="text/css" />
<!--[if lte IE 6]>
<style type="text/css">
#hornav ul li, #hornav ul li a, #wrapper-content-1, #wrapper-content-2, #list-rss li a {height:1%;}
</style>
<![endif]-->
<!--[if lt IE 6]>
<style type="text/css">
.vertnav a { width: 147px; }
</style>
<![endif]-->
<style type="text/css">
<!--
.style1 {font-size: 12px}
.style2 {font-size: 16px}
.style3 {font-size: 14px}
-->
</style>
</head>
<body bgcolor="#3333FF">
<div id="wrapper-1">
<div id="page-top"> </div>
<div id="branding">
<h1></h1>
</div>
<div id="hornav">
<ul>
<li><a id="current" href="#">Home</a></li>
<li><a href="index2.htm">What</a></li>
<li><a href="#">Links</a></li>
<li><a href="#">To</a></li>
<li><a href="#">Use</a></li>
<li><a href="#">?</a></li>
</ul>
</div>
<div id="wrapper-content-1">
<div id="content-1-left">
<h2 class="rounded-heading"><span>Content 1.1?</span></h2>
<div class="content-padder">
<!-- Images no more than 400px wide! -->
<p>
<object width="320" height="265"><param name="movie" value="http://www.youtube-nocookie.com/v/W4LELQfeT7E&hl=en&fs=1&rel=0&color1=0x3a3a3a&color2=0x999999"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube-nocookie.com/v/W4LELQfeT7E&hl=en&fs=1&rel=0&color1=0x3a3a3a&color2=0x999999" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="320" height="265"></embed></object>
</p>
<p> </p>
<p class="style2">Please take a few moments to listen to this message from one of our Leads, Marissa Livengood. </p>
</div>
</div>
<div id="content-1-right">
<h2 class="rounded-heading"><span>Contact Livengood Investments </span></h2>
<div class="content-padder">
<?
// Print form field errors if present
if (count($contacter_form_error)>0){
print '<p id="bottom"><strong>Something is amiss:</strong></p>'."\n";
print '<ul>'."\n";
foreach($contacter_form_error as $form_err) {
print "<li class=\"error\">$form_err</li>\n";
}
print '</ul>'."\n";
}
?>
<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="contact_phone">Your Telephone Number <span class="required">*</span></label>
<br />
<input type="text" id="contact_phone" name="contact_phone" size="30" value="<? print $_POST['contact_phone']; ?>" />
<br />
<label for="best_time">Best time to contact you</label>
<br />
<select id="best_time" name="best_time">
<option value="">Choose a time</option>
<option value="Morning">Morning 8a-11a</option>
<option value="Afternoon">Afternoon 12p-5p</option>
<option value="Evening">Evening 5p-9p</option>
</select>
</fieldset>
<fieldset>
<legend>Your Comment</legend>
<label for="contact_comment">Comment Text</label>
<br />
<textarea name="contact_comment" cols="30" rows="5" id="contact_comment"><? print $contact_comment; ?></textarea>
</fieldset>
<p>
<input type="hidden" name="sendcontact" value="contactsent" />
<input type="submit" value="Send Email" />
</p>
<p class="style1">(By submitting this form, you are requesting us to contact you)</p>
</div>
</form>
As I'm sure you can imagine, I'm a complete newbie to PHP... more HTML kinda guy, but trying to learn something new and if I can get the email to actually come to me, I'll be all set. Thanks in advance!