so here’s the problem: when the email is sent to me from my site, it doesn’t include the name or email addy IN THE MESSAGE. I somehow got the email addy to appear in the email subject. I’m extremely new to PHP and I’m trying to learn it, but this isn’t making sense to me. Also, I had someone suggest that I “It’s not a snag, you simply need to assign the $name and $check_email variables to the $check_email variable before calling the mail function.” I have no clue as to what that means. :S
Here’s my html:
<?php
$status = $_GET['status'];
if($status=="1") {
echo '<div class="successAlert" style="width:350px; margin:0px;">Message successfully sent!</div>';
} elseif ($status=="0") {
echo '<div class="warningAlert" style="width:350px; margin:0px;">Your message was not sent.<br>Please check your info!</div>';
} else {
echo"";
}
?>
<form method="post" id="form1" class="form" action="send_email.php">
<table width="392" height="245px" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="90"><label for="name" title="name"><span>Your name:</span></label></td>
<td width="300"><div align="left"><input class="name" type="text" name="name" id="name" size="32" /></div> </td>
</tr>
<tr>
<td><label for="email" title="email"><span>Your email:</span></label></td>
<td><div align="left"><input class="email" type="text" name="email" id="email" size="32" /></div> </td>
</tr>
<tr>
<td><label for="message"><span>Your message:</span></label></td>
<td><div align="left">
<textarea name="message" cols="32" rows="5" class="textarea" id="message" ></textarea>
</div></td>
</tr>
<tr>
<td colspan="2"><div align="right">
<input class="buttons" type="image" src="img/button.png"name="Send message" id="Send message" value="Send message →" />
</div></td>
</tr>
</table>
</form>
Here’s my php code
<?php
$site_name = "EricDMunoz.com";
$admin_email = "eric@ericdmunoz.com";
function check_email_address($email) {
// First, we check that there's one @ symbol, and that the lengths are right
if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $email)) {
// Email invalid because wrong number of characters in one section, or wrong number of @ symbols.
header("Location: contact.php?status=0");
}
// Split it into sections to make life easier
$email_array = explode("@", $email);
$local_array = explode(".", $email_array[0]);
for ($i = 0; $i < sizeof($local_array); $i++) {
if (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$", $local_array[$i])) {
header("Location: contact.php?status=0");
}
}
if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) { // Check if domain is IP. If not, it should be valid domain name
$domain_array = explode(".", $email_array[1]);
if (sizeof($domain_array) < 2) {
die ("Invalid email address");// Not enough parts to domain
}
for ($i = 0; $i < sizeof($domain_array); $i++) {
if (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$", $domain_array[$i])) {
header("Location: contact.php?status=0");
}
}
}
return $email;
}
function escape_val($string) {
$string = str_replace(array('"',"<",">"), array(""","<",">"), $string);
return $string;
}
$name = escape_val($_REQUEST['name']);
$check_email = check_email_address($_REQUEST['email']);
$email_message = escape_val($_REQUEST['message']);
$time = date('l dS \of F Y h:i:s A');
$email_subject = "New contact message from ".$check_email."";
if(mail($admin_email,$email_subject,$email_message,"From:$check_email,Reply-to:$check_email")) {
header("Location: contact.php?status=1");
exit;
} else {
header("Location: contact.php?status=0");
}
?>
Any ideas as to how to fix this snag?