Current location: Hot Scripts Forums » Programming Languages » PHP » Question about a form mail script


Question about a form mail script

Reply
  #1 (permalink)  
Old 07-22-06, 12:48 PM
9999 9999 is offline
Newbie Coder
 
Join Date: Jul 2006
Posts: 86
Thanks: 0
Thanked 0 Times in 0 Posts
Question about a form mail script

Form mail script
PHP Code:

<?

///////////////////////////////////////////////////////////////////
// PERFECT //
// ------- //
// PHP E-mail Receive Form Electronic Content Text //
// File: feedback.php //
// Version: 1.6 (April 2, 2004) //
// Description: Processes a web form to read the user input and //
// then send the data to a predefined recipient. You are //
// free to use and modify this script as you like. //
// Instructions: Go to "http://www.centerkey.com/php". //
// //
// Center Key Software * www.centerkey.com * Dem T. Pilafian //
///////////////////////////////////////////////////////////////////

// Configuration Settings
$SendFrom "Form Feedback <feedback@yourdomain.com>";
$SendTo "feedback@yourdomain.com";
$SubjectLine "Feedback Submission";
$ThanksURL "thanks.html"//confirmation page
$Divider "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~";

// Build Message Body from Web Form Input
$MsgBody = @gethostbyaddr($_SERVER["REMOTE_ADDR"]) . "\n$Divider\n";
foreach (
$_POST as $Field=>$Value)
$MsgBody .= "$Field$Value\n";
$MsgBody .= "$Divider\n" $_SERVER["HTTP_USER_AGENT"] . "\n";
$MsgBody htmlspecialchars($MsgBody); //make content safe

// Send E-Mail and Direct Browser to Confirmation Page
mail($SendTo$SubjectLine$MsgBody"From: $SendFrom");
header("Location: $ThanksURL");
?>
1) If I want the $SendFrom line to display the actual name and email the user submits in a form, why wouldn't this work
PHP Code:

$SendFrom =    'Form Mail - '.$_POST['Name']. '<' $POST['Email'] . '>'
I want it to look like this: Form Mail - John Doe <jonhndoe@hotmail.com> for example.

2) Is this script pretty secure for a form mail? If not, what suggestions do you have?
Reply With Quote
  #2 (permalink)  
Old 07-22-06, 01:04 PM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
Quote:
Originally Posted by 9999
why wouldn't this work
PHP Code:

$SendFrom =    'Form Mail - '.$_POST['Name']. '<' $POST['Email'] . '>'
Since you don't tell us what exactly doesn't work, can I only guess. But this:
PHP Code:

$POST['Email'
Should be this:
PHP Code:

$_POST['Email'
Reply With Quote
  #3 (permalink)  
Old 07-22-06, 01:16 PM
9999 9999 is offline
Newbie Coder
 
Join Date: Jul 2006
Posts: 86
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks. I overlooked that.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Script to create backend of form? tb582 Job Offers & Assistance 3 03-16-06 10:50 AM
PHP script problem (please help) osmanmumtaz PHP 0 05-24-05 07:29 AM
Request: text form and image uploading script (PHP) YHIEddie Script Requests 0 03-18-05 05:22 PM
Modifying a script for form insertion px0 PHP 1 06-08-04 05:46 PM
form question delerium PHP 5 01-19-04 10:30 PM


All times are GMT -5. The time now is 07:22 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.