PHP Contact Form Help

Soldato
Joined
19 Dec 2007
Posts
2,663
Location
Newton Aycliffe
Code:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Sending...</title>
</head>
<?php 
$to = "[email protected]"; 
$subject = "Contact recieved from Jonnyisms";
$name = $_REQUEST['name'] ;
$email = $_REQUEST['email'] ; 
$message = $_REQUEST['message']; 
$headers = "From: $email"; 
$sent = mail($to, $subject, $message, $headers) ; 
if($sent) 
{print "Thank you $name, Your mail was sent successfully."; }
else 
{print "We encountered an error sending your mail, please click back on your browser."; }
?>
<body>
</body>
</html>

I have the above as a php page which processes the contact form on my website, my questions are:

1. how can i get this page to automatically forward the user back onto a page in my website.

2. how can i get the email to display the name of the sender as well, at the moment I have it collecting the user's name but it is only used in a line to thank them for sending.
 
Thanks, that's excellent, I have used the java script there so I can leave the success message as it is. :)

Just need to sort the name sending now, as if I get the message from someone with a random email I wont know what they're called!
 
I have used both solutions there, so not it tells me in my message (using option 1) and in the from field using Xtrm2Matt's solution.

thanks mucho!
 
Back
Top Bottom