hari4u2
Regular Member
- Jun 23, 2010
- 201
- 47
Need Help With PHP Email
if anybody contacts me not showing there email id in mail. its showing my server mail id
what can i do ?
Code:
<?php /* Set e-mail recipient */
$myemail = "[email protected]";
/* Check all form inputs using check_input function */
$name = check_input($_POST['name'], "Enter your name");
$subject = check_input($_POST['subject'], "Enter your subject");
$email = check_input($_POST['email']);
$phone = check_input($_POST['phone']);
$message = check_input($_POST['message']);
/* If e-mail is not valid show error message */
if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email))
{
show_error("E-mail address not valid");
}
/* Let's prepare the message for the e-mail */
$message = "Hello!
Name: $name
E-mail: $email
Phone: $phone
Subject: $subject
Mail Message:
$message
End of message
";
/* Send the message using mail() function */
mail($myemail, $subject, $message);
/* Redirect visitor to the thank you page */
header("Location: index.html");
exit();
/* Functions we used */
function check_input($data, $problem='')
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
if ($problem && strlen($data) == 0)
{
show_error($problem);
}
return $data;
}
function show_error($myError)
{
?>
<html>
<body>
<b>Please correct the following error:</b><br />
<?php echo $myError; ?>
</body>
</html>
<?php
exit();
}
?>
if anybody contacts me not showing there email id in mail. its showing my server mail id
what can i do ?