Hi all and happy holidays!
I should start off by stating I am NOT a PHP programmer.
I say that so that in any response to me, you will speak very s-l-o-w-l-y or I won't know what you're talking about ;-)
I have this form processor script that I basically pieced together from 3 different scripts.
The script includes a CAPTCHA image verification, which works fine.
The problem I am having is that when the form is processed, the results e-mailed to me also include the $key and $val for both the verification number ('secure') and the 'Submit' function.
Here is that section of the HTML:
[HTML]
<tr>
<td>Security Code</td>
<td><input type="text" name="secure"/>
</td>
</tr>
<tr>
<td><img src="captcha_im age.php" alt="security image" border="0"/></td>
<td>
<input type="submit" name="submit" value="Send"/></td>
</tr>
[/HTML]
Now, is there any way to have all the data entered into the form sent to me except for the "secure" and "submit"?
Also, it would be nice to have form results sent to me read like:
Event Description:
instead of:
event_descripti on
but that is not my main concern.
Anyway, below is the code in question.
Thanks :)
[php]
<?php
session_start() ;
//PAGE VARS
$err = '';
$Message = '';
//FORM PROCESSING
if (isset($_POST['submit'])) {
// clean and check form inputs including the secure image code
$name = trim(strip_tags ($_POST['name']));
$email = trim(strip_tags ($_POST['email']));
$phone = trim(strip_tags ($_POST['phone']));
$event_title = trim(strip_tags ($_POST['event_title']));
$event_date_and _time = trim(strip_tags ($_POST['event_date_and _time']));
$event_location = trim(strip_tags ($_POST['event_location ']));
$event_phone_nu mber = trim(strip_tags ($_POST['event_phone_nu mber']));
$event_price = trim(strip_tags ($_POST['event_price']));
$event_descript ion = trim(strip_tags ($_POST['event_descript ion']));
$secure = strtoupper(trim (strip_tags($_P OST['secure'])));
$match = $_SESSION['captcha']; // the code on the image
// input error checking
if ($name=="") {
$err.= "Please provide your name<br/>";
}
if (!$email) {
$err.= "Please provide your email address<br>";
}
if ($email) {
if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) {
$err.= $email. " is not a valid email address.<br/>";
}
}
if ($phone=="") {
$err.= "Please provide your phone number<br/>";
}
if ($event_title== "") {
$err.= "Please provide the title of the event<br/>";
}
if ($event_date_an d_time=="") {
$err.= "Please provide the date and time of the event<br/>";
}
if ($event_locatio n=="") {
$err.= "Please provide the location of the event<br/>";
}
if ($event_phone_n umber=="") {
$err.= "Please provide a phone number for the venue<br/>";
}
if ($event_price== "") {
$err.= "Please provide the price to attend the event<br/>";
}
if ($event_descrip tion=="") {
$err.= "Please provide a description for the event<br/>";
}
if (!$secure) {
$err.= "No security code entered<br/>";
}
if (($secure!=$mat ch) && ($secure!="")) {
$err.= "Security code mismatch<br/>";
}
//if error free
if ($err=="") {
//Start Pieced in
$MailToAddress = "rik408@yahoo.c om";
$MailSubject = "Club Event Submission";
$MailFromAddres s = ( isset($email) && $email != '') ? $email : 'noReply@myDoma in.com';
//end pieced in
//start pieced in: this may be a major trouble spot, since it is preceeded by another "if" statement
if (!is_array($HTT P_POST_VARS))
return;
reset($HTTP_POS T_VARS);
while(list($key , $val) = each($HTTP_POST _VARS)) {
$GLOBALS[$key] = $val;
$val=stripslash es($val);
$Message .= "$key = $val\n";
}
mail( "$MailToAddress ", "$MailSubje ct", "$Message", "From: $MailFromAddres s");
header("Locatio n: http://www.metroactive .com/contact/thanks.html");
//end pieced in
exit();
}//end if error free
}// end if submit
//PAGE PROCESSING
?>
[/php]
[html]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Trolls go away</title>
<style type="text/css">
body,td {
font-family:arial, helvetica, sans-serif;
background:#fff ;
color:#000;
font-size:12px;
}
input, textarea {
background:#eee ;
color:#000;
font-size:12px;
border:1px solid #000;
}
</style>
</head>
<body>
<?php
if ($err!="") {
echo "<strong>Fo rm Error(s)</strong><br/>";
echo "<font color='#cc3300' >". nl2br($err). "</font><br/>";
}
?>
<form name="captcha" method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
<table cellpadding="3" cellspacing="2" style="border:1 px dotted #667;">
<tr>
<td>Name:</td><td><input type="text" name="name" value="<?php if(isset($_POST['name']))echo $_POST['name'];?>"/></td>
</tr>
<tr>
<td>Email:</td><td><input type="text" name="email" value="<?php if(isset($_POST['email']))echo $_POST['email'];?>"/></td>
</tr>
<tr>
<td>Daytime Phone: </td>
<td><input type="text" name="phone" value="<?php if(isset($_POST['phone']))echo $_POST['phone'];?>"/></td>
</tr>
<tr>
<td>Club Event Title:</td><td><input type="text" name="event_tit le" value="<?php if(isset($_POST['event_title']))echo $_POST['event_title'];?>"/></td>
</tr>
<tr>
<td>Date and Time:</td><td><input type="text" name="event_dat e_and_time" value="<?php if(isset($_POST['event_date_and _time']))echo $_POST['event_date_and _time'];?>"/></td>
</tr>
<tr>
<td>Location: </td><td><input type="text" name="event_loc ation" value="<?php if(isset($_POST['event_location ']))echo $_POST['event_location '];?>"/></td>
</tr>
<tr>
<td>Venue Phone Number:</td><td><input type="text" name="event_pho ne_number" value="<?php if(isset($_POST['event_phone_nu mber']))echo $_POST['event_phone_nu mber'];?>"/></td>
</tr>
<tr>
<td>Price</td><td><input type="text" name="event_pri ce" value="<?php if(isset($_POST['event_price']))echo $_POST['event_price'];?>"/></td>
</tr>
<tr>
<td valign="top">Ev ent Description:</td>
<td><textarea rows="5" columns="30" name="event_des cription"><?php if(isset($_POST['event_descript ion']))echo $_POST['event_descript ion'];?></textarea></td>
</tr>
<tr>
<td>Security Code</td>
<td><input type="text" name="secure"/>
</td>
</tr>
<tr>
<td><img src="captcha_im age.php" alt="security image" border="0"/></td>
<td>
<input type="submit" name="submit" value="Send"/></td>
</tr>
</table>
</form>
</body>
</html>
[/html]
I should start off by stating I am NOT a PHP programmer.
I say that so that in any response to me, you will speak very s-l-o-w-l-y or I won't know what you're talking about ;-)
I have this form processor script that I basically pieced together from 3 different scripts.
The script includes a CAPTCHA image verification, which works fine.
The problem I am having is that when the form is processed, the results e-mailed to me also include the $key and $val for both the verification number ('secure') and the 'Submit' function.
Here is that section of the HTML:
[HTML]
<tr>
<td>Security Code</td>
<td><input type="text" name="secure"/>
</td>
</tr>
<tr>
<td><img src="captcha_im age.php" alt="security image" border="0"/></td>
<td>
<input type="submit" name="submit" value="Send"/></td>
</tr>
[/HTML]
Now, is there any way to have all the data entered into the form sent to me except for the "secure" and "submit"?
Also, it would be nice to have form results sent to me read like:
Event Description:
instead of:
event_descripti on
but that is not my main concern.
Anyway, below is the code in question.
Thanks :)
[php]
<?php
session_start() ;
//PAGE VARS
$err = '';
$Message = '';
//FORM PROCESSING
if (isset($_POST['submit'])) {
// clean and check form inputs including the secure image code
$name = trim(strip_tags ($_POST['name']));
$email = trim(strip_tags ($_POST['email']));
$phone = trim(strip_tags ($_POST['phone']));
$event_title = trim(strip_tags ($_POST['event_title']));
$event_date_and _time = trim(strip_tags ($_POST['event_date_and _time']));
$event_location = trim(strip_tags ($_POST['event_location ']));
$event_phone_nu mber = trim(strip_tags ($_POST['event_phone_nu mber']));
$event_price = trim(strip_tags ($_POST['event_price']));
$event_descript ion = trim(strip_tags ($_POST['event_descript ion']));
$secure = strtoupper(trim (strip_tags($_P OST['secure'])));
$match = $_SESSION['captcha']; // the code on the image
// input error checking
if ($name=="") {
$err.= "Please provide your name<br/>";
}
if (!$email) {
$err.= "Please provide your email address<br>";
}
if ($email) {
if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) {
$err.= $email. " is not a valid email address.<br/>";
}
}
if ($phone=="") {
$err.= "Please provide your phone number<br/>";
}
if ($event_title== "") {
$err.= "Please provide the title of the event<br/>";
}
if ($event_date_an d_time=="") {
$err.= "Please provide the date and time of the event<br/>";
}
if ($event_locatio n=="") {
$err.= "Please provide the location of the event<br/>";
}
if ($event_phone_n umber=="") {
$err.= "Please provide a phone number for the venue<br/>";
}
if ($event_price== "") {
$err.= "Please provide the price to attend the event<br/>";
}
if ($event_descrip tion=="") {
$err.= "Please provide a description for the event<br/>";
}
if (!$secure) {
$err.= "No security code entered<br/>";
}
if (($secure!=$mat ch) && ($secure!="")) {
$err.= "Security code mismatch<br/>";
}
//if error free
if ($err=="") {
//Start Pieced in
$MailToAddress = "rik408@yahoo.c om";
$MailSubject = "Club Event Submission";
$MailFromAddres s = ( isset($email) && $email != '') ? $email : 'noReply@myDoma in.com';
//end pieced in
//start pieced in: this may be a major trouble spot, since it is preceeded by another "if" statement
if (!is_array($HTT P_POST_VARS))
return;
reset($HTTP_POS T_VARS);
while(list($key , $val) = each($HTTP_POST _VARS)) {
$GLOBALS[$key] = $val;
$val=stripslash es($val);
$Message .= "$key = $val\n";
}
mail( "$MailToAddress ", "$MailSubje ct", "$Message", "From: $MailFromAddres s");
header("Locatio n: http://www.metroactive .com/contact/thanks.html");
//end pieced in
exit();
}//end if error free
}// end if submit
//PAGE PROCESSING
?>
[/php]
[html]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Trolls go away</title>
<style type="text/css">
body,td {
font-family:arial, helvetica, sans-serif;
background:#fff ;
color:#000;
font-size:12px;
}
input, textarea {
background:#eee ;
color:#000;
font-size:12px;
border:1px solid #000;
}
</style>
</head>
<body>
<?php
if ($err!="") {
echo "<strong>Fo rm Error(s)</strong><br/>";
echo "<font color='#cc3300' >". nl2br($err). "</font><br/>";
}
?>
<form name="captcha" method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
<table cellpadding="3" cellspacing="2" style="border:1 px dotted #667;">
<tr>
<td>Name:</td><td><input type="text" name="name" value="<?php if(isset($_POST['name']))echo $_POST['name'];?>"/></td>
</tr>
<tr>
<td>Email:</td><td><input type="text" name="email" value="<?php if(isset($_POST['email']))echo $_POST['email'];?>"/></td>
</tr>
<tr>
<td>Daytime Phone: </td>
<td><input type="text" name="phone" value="<?php if(isset($_POST['phone']))echo $_POST['phone'];?>"/></td>
</tr>
<tr>
<td>Club Event Title:</td><td><input type="text" name="event_tit le" value="<?php if(isset($_POST['event_title']))echo $_POST['event_title'];?>"/></td>
</tr>
<tr>
<td>Date and Time:</td><td><input type="text" name="event_dat e_and_time" value="<?php if(isset($_POST['event_date_and _time']))echo $_POST['event_date_and _time'];?>"/></td>
</tr>
<tr>
<td>Location: </td><td><input type="text" name="event_loc ation" value="<?php if(isset($_POST['event_location ']))echo $_POST['event_location '];?>"/></td>
</tr>
<tr>
<td>Venue Phone Number:</td><td><input type="text" name="event_pho ne_number" value="<?php if(isset($_POST['event_phone_nu mber']))echo $_POST['event_phone_nu mber'];?>"/></td>
</tr>
<tr>
<td>Price</td><td><input type="text" name="event_pri ce" value="<?php if(isset($_POST['event_price']))echo $_POST['event_price'];?>"/></td>
</tr>
<tr>
<td valign="top">Ev ent Description:</td>
<td><textarea rows="5" columns="30" name="event_des cription"><?php if(isset($_POST['event_descript ion']))echo $_POST['event_descript ion'];?></textarea></td>
</tr>
<tr>
<td>Security Code</td>
<td><input type="text" name="secure"/>
</td>
</tr>
<tr>
<td><img src="captcha_im age.php" alt="security image" border="0"/></td>
<td>
<input type="submit" name="submit" value="Send"/></td>
</tr>
</table>
</form>
</body>
</html>
[/html]
Comment