PDA

View Full Version : PHP Feedback form Query



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

I´ve 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. I´d prefer this message to be shown in place of the form instead of opening an entirely new page.

Here is the PHP code I´m using on the page:

<?php

$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
<br><hr><br>
Name: $nombreField <br>
Apellido: $apellidoField <br>
Email: $emailField <br>
Telefono: $telefonoField <br>
Comentarios: $comentariosField <br>
EOD;


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

$theResults=<<<EOD
<html>
<head>
<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;
}
-->
</style>
</head>

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

echo "$theResults";

?>


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