<!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" xml:lang="en" lang="en">
<head>
<title>Tell A Friend Script</title>
</head>
<body>
<form action="thank-page.php" method="post">
Your Name : <br />
<input name="name" type="text"><br /><br />
Friend's Email Address : <br />
<input name="email" type="text"><br /><br />
<input name="Send" type="submit" value="Send">
</form>
thank-page.php
<?
if (@$_POST['Send']=="Send")
{
$name=$_POST['name'];
$email=$_POST['email'];
$subject = $name. " recommends this site !";
$message= "Hello, \n\n" .$name. " thought you might be interested in visiting the following website : \n\nYour Website here - http://www.yourwebsite.com \n\n\n\n\n\n\n\nNote: This message was not sent unsolicited. It was sent through a form located at http://www.yourwebsite.com If you believe this message was received on error, please disregard it.";
$headers = 'From: youremail@youremail.com' . "\r\n" . 'Reply-To: youremail@youremail.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion();
mail($email, $subject, $message, $headers);
echo "Your email was sent to: $email";
}
?>
</body>
</html>
My god … I have not thinned about it that anyone write code for me. Why you are have this misconceptions about this. Why we take help to you all becouse you have all knowledge shop. Sharing if knowledge increase your idea and my feelings about you.
You do not even provide information about what “not working” means. How should anyone know? Are you suggestion anyone else than you will test this for you? Nor you have said what you have done by yourself trying to find a solution. I do not see that you take responsibility for your project anywhere - not even after i mentioned some hints to get you helped by yourself.
I think what everyone is getting at is - in what way does it “not work”? Does it not execute at all, does it seem to work but you don’t get an email, is the email formatted badly, do you get any error messages? How far through the code do you get before it stops working?
ETA - I see you are using the mail() function. There are several discussions on sending emails from PHP just in the last week that suggest alternatives because that function is apparently unreliable.
just start all over with a new file and bring back every line, one at a time. should not be too complicated to see when the error starts for 10 lines of code.
I’ve duplicated your problem, getting a blank screen on submission, and fixed it (ETA on my localhost). I suggested the solution in post #14, so have a look through those points and see which one helps.
I can’t test the mailing side, as I don’t have that configured. But I do get a message suggesting the mail was sent, after the error about mail() not being configured.
<?
if (var_dump($_POST)
{
$name=$_POST['name'];
$email=$_POST['email'];
$subject = $name. " recommends this site !";
$message= "Hello, \n\n" .$name. " thought you might be interested in visiting the following website : \n\nYour Website here - http://www.yourwebsite.com \n\n\n\n\n\n\n\nNote: This message was not sent unsolicited. It was sent through a form located at http://www.yourwebsite.com If you believe this message was received on error, please disregard it.";
$headers = 'From: youremail@youremail.com' . "\r\n" . 'Reply-To: youremail@youremail.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion();
mail($email, $subject, $message, $headers);
echo "Your email was sent to: $email";
}
?>