Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

PHP Self Processing Form

Explorer ,
Nov 09, 2006 Nov 09, 2006
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!

TOPICS
Server side applications
470
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Nov 10, 2006 Nov 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']);
}...
Translate
LEGEND ,
Nov 10, 2006 Nov 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.


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 14, 2006 Nov 14, 2006
LATEST
Thanks Gareth! That's done the trick!
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines