Tell-a-Friend

<!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>

Not Working…

maybe you want to start fixing it?

maybe you start over reading what others already told you:

just a hint: var_dump(), PHPMailer

1 Like

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 have not need to suggest personally.

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 tried but I not get

I see no try. I do not even see you using any function i mentioned.

After try or generation of code I posted .When it nit worked.

ignoring the main part of what i said did not work? really?

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.

2 Likes

No any error show only bank page and not get any email.

Do you have error reporting switched on?

Is your server configured to allow short PHP tags? And remove error-suppression. What about if you var_dump($_POST), what does that show?

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 don’t know what you’re saying boss.
Please check it on your local host.atomatically you got answer.

How is @droopsnoot checking the settings on his localhost going to help you remove error suppression on yours?

1 Like

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.

1 Like

As I understand…

<?
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";
}
?>

Now is this is correct?

You’ll get an error message there, because you open more brackets than you close.

Does it work, when you correct the brackets?

1 Like