Page 1 of 1

Feedback form

Posted: Sat Oct 09, 2004 3:56 pm
by RumRat
I am a real newbie to PHP and have a feedback form on my site and would like to add some extra fields to the existing form.

At present all I have is Name, Email Address and Comments. I would like to add the following fields: A visitors URL (Not a required field) Select country A required drop down box and how did you find us?, also a d/d box
The present code I have is:

Code: Select all

$name = $_POST['name'] ;
$email = $_POST['email'] ;
$comments = $_POST['comments'] ;
$http_referrer = getenv( "HTTP_REFERER" );

if (!isset($_POST['email'])) {
	header( "Location: $formurl" );
	exit ;
}
if (empty($name) || empty($email) || empty($comments)) {
   header( "Location: $errorurl" );
   exit ;
}
if (get_magic_quotes_gpc()) {
	$comments = stripslashes( $comments );
}

$messageproper =

	"This message was sent from:\n" .
	"$http_referrer\n" .
	"------------------------- COMMENTS -------------------------\n\n" .
	$comments .
	"\n\n------------------------------------------------------------\n" ;

mail($mailto, $subject, $messageproper, "From: "$name" <$email>\nReply-To: "$name" 
<$email>\nX-Mailer: chfeedback.php 2.02" );
header( "Location: $thankyouurl" );
exit ;

?>
Can anyone suggest what I do now?

Many, many thanks

Ken

Posted: Sat Oct 09, 2004 4:00 pm
by twigletmac
You would first need to add these to the HTML form - then you can gather the information from them in the same way you do for the other fields. Checking whether required fields are filled or not would mean an addition of more conditions to this line:

Code: Select all

if (empty($name) || empty($email) || empty($comments)) {
Mac