View Full Version : PHP Feedback form Query

19 Jan 2010, 12:05 PM
Hi all - This is my 1st post which hopefully someone with a bit of experience can answer very easily! -

Ive created a basic feedback form for my website using PHP and it is funcioning correctly (sending an email to the webmaster with contact details.)

However, when the user sends the form, they are taken to a new page with the generic "Thanks for entering your details etc" message. Id prefer this message to be shown in place of the form instead of opening an entirely new page.

Here is the PHP code Im using on the page:


$emailSubject = 'form feedback' ;
$webMaster = 'me@myemailaddress.com' ;

/* variables to gather data! */

$nombreField = $_POST['nombre'];
$apellidoField = $_POST['apellido'];
$emailField = $_POST['email'];
$telefonoField = $_POST['telefono'];
$comentariosField = $_POST['comentarios'];

$body = <<<EOD
Name: $nombreField <br>
Apellido: $apellidoField <br>
Email: $emailField <br>
Telefono: $telefonoField <br>
Comentarios: $comentariosField <br>

$headers = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail($webMaster, $emailSubject, $body, $headers);

<title>Thanks for your info</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
body {
background-color: #f1f1f1;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
font-style: normal;
line-height: normal;
font-weight: normal;
color: #666666;
text-decoration: none;

<div align="left">Thank you for your interest! Your email will be answered very soon!</div>

echo "$theResults";


Any tips on how to move forward with this greatly appreciated!