Skip to main content
Participant
November 10, 2006
Answered

PHP Self Processing Form

  • November 10, 2006
  • 2 replies
  • 467 views
Hi
I'm tring to adapt a form processing script that appears in the book "PHP Web Development with Macromedia Dreamweaver MX 2004" published by Apress. The example in the book has a simple form containing a "comments" field and a "email" and "confirm your email" fields. The script works fine but the form I need has a few more fields. ie. "name" and "telephone". How can I alter the attached script so that the contents of these extra fields are sent along with the rest of the email?

Thanks for your help!

This topic has been closed for replies.
Correct answer Newsgroup_User
After

if (isset($_POST['comments']) && !empty($_POST['comments'])) {
$message=strip_tags($_POST['comments']);
}
else {
$nomessage = 'You have not entered any comments';
}

And using the same syntax as above add:

if (isset($_POST['name']) && !empty($_POST['name'])) {
$message .= "\n";
$message .= "Name: " . strip_tags($_POST['name']);
}

if (isset($_POST['telephone']) && !empty($_POST['telephone'])) {
$message .= "\n";
$message .= "Telephone: " . strip_tags($_POST['telephone']);
}

\n is the newline character for emails

Gareth
http://www.phploginsuite.co.uk/
PHP Login Suite V2 - 34 Server Behaviors to build a complete Login system.


2 replies

maffewAuthor
Participant
November 14, 2006
Thanks Gareth! That's done the trick!
Newsgroup_UserCorrect answer
Inspiring
November 10, 2006
After

if (isset($_POST['comments']) && !empty($_POST['comments'])) {
$message=strip_tags($_POST['comments']);
}
else {
$nomessage = 'You have not entered any comments';
}

And using the same syntax as above add:

if (isset($_POST['name']) && !empty($_POST['name'])) {
$message .= "\n";
$message .= "Name: " . strip_tags($_POST['name']);
}

if (isset($_POST['telephone']) && !empty($_POST['telephone'])) {
$message .= "\n";
$message .= "Telephone: " . strip_tags($_POST['telephone']);
}

\n is the newline character for emails

Gareth
http://www.phploginsuite.co.uk/
PHP Login Suite V2 - 34 Server Behaviors to build a complete Login system.