ttomnmo Posted November 9, 2006 Share Posted November 9, 2006 I am having a little trouble fitting this to my needs. I got this script on a free download from CJ designs. It works but I am having troubles adjusting it. It is just a form that when filled out and sent, sends the info to the recipient in an email. I wanted to change some of the form entries and have gotten the subject titles to show up on the email, but where the info from the form should be there is nothing. I am trying to add the honorees name, and the comments. Can someone help me? The code is divided into the following four pages.web2mailconfig.php<?$yourname = "Sharon Roberts Cancer Foundation";$your_website = "Sharons Hope";$your_webaddress = "http://sharonshope.org";$admin_email = "[email protected]";$subject = "Honor Roll Submision";$show_ip = "no"; $auto_responder = "no";$auto_subject = "Auto Responder";$error_messages = "yes";$multipart_emails = "yes";$html_font = "verdana";$html_font_size = "10pt";$alink_color = "#11116E";$vlink_color = "#11116E";$hlink_color = "#000000";$default_thank_msg = "yes";$thankyou_message_url = "http://sharonshope.org/index.html";?>web2mail.php<?include "web2mail_config.php";$path = __FILE__;$path = preg_replace( "'\\\web2mail\.php'", "", $path);$path = preg_replace( "'/web2mail\.php'", "", $path);$send = false;if(isset($_POST['submit'])){ $date = date("l d F Y"); $time = date("g:i:s a"); $ermsg = ""; $send = true; $ip = $_SERVER['REMOTE_ADDR']; $name = cleanUp($_POST['name']); $email = cleanUp($_POST['email']); $honoree = cleanUp($_POST['honoree']); $comments = cleanUp($_POST['comments']); $emailvalid = is_valid_email($email); if (!isset($name) || $name == ""){ $emsg = "<li>Please enter your name"; $send = false; } if (!isset($email) || $email == "" || $emailvalid == 1){ $emsg .= "<li>Your email address is missing or incorrect"; $send = false; } if (!isset($honoree) || $honoree == ""){ $emsg = "<li>Please enter the name of the person you wish to honor"; $send = false; } if($send){ $sent = false; include("mail_functions.php"); $message = strip_tags($message); $message = stripslashes($message); if($multipart_emails == "yes"){ if(sendHTMLEmail($name, $email, $message, $subject, $recipient, $ip, $date, $time)){ $sent = true; } } else{ $recipient = "$yourname <$admin_email>"; $headers = "From: $name <$email>\r\nReply-To: $email\r\n"; $msg = "Submitted: $date - $time\nFrom: $name - $email\n\n\n$message\n\nIP: $ip\n\n\nPowered by CJ Web2Mail V3.0 © http://www.cj-design.com"; if(mail ($recipient, $msg, $headers)){ $sent = true; } } if($sent){ if($auto_responder == "yes"){ if($multipart_emails == "yes"){ sendHTMLEmailAuto($name, $email, $subject); } else{ sendTextEmailAuto($name, $email, $subject); } } if($default_thank_msg == "yes"){ include($path."/thankyou.php"); } else{ header("Location: $thankyou_message_url"); } } else{ include($path."/thankyou.php"); } } }if(!$send){ if(strlen($emsg) > 0 && $error_messages == "yes"){ echo "Your submission had the following errors:<br><br><FONT COLOR=\"red\">$emsg</FONT><br><br>"; } include($path."/form.php"); }function cleanUp($field){ //Remove line feeds $ret = str_replace("\r", "", $field); $ret = str_replace("\n", "", $ret); // Remove injected headers $find = array("/bcc\:/i", "/Content\-Type\:/i", "/Mime\-Type\:/i", "/cc\:/i", "/to\:/i"); $ret = preg_replace($find, "", $ret); return $ret;}function is_valid_email($sender_mail) { if(ereg("([[:alnum:]\.\-]+)(\@[[:alnum:]\.\-]+\.+)", $sender_mail)) { return 0; } else{ return 1; } }?>form.php<form action="<? echo $_SERVER['PHP_SELF']; ?>" method="POST"><table width="100%"><tr> <td align="left" width="22%"><div align="right">Your Name: </div></td> <td align="left" width="78%"><input type="text" name="name" size="30" value="<? echo $_POST['name']; ?>"></td></tr><tr><td align="left" width="22%"><div align="right">Your E-mail:</div></td><td align="left" width="78%"><input type="text" name="email" size="30" value="<? echo $_POST['email']; ?>"></td></tr><tr> <td align="left" width="22%"><div align="right">Honoree's Name: </div></td> <td align="left" width="78%"><input name="honoree" type="text" value="<? echo $_POST['honoree']; ?>" size="30"></td></tr><tr> <td width="22%" height="" align="left"><div align="right">Comments:</div></td> <td width="78%" align="left"> <p align="left"> <textarea cols="40" rows="3" name="comments"><? echo $_POST['comments']; ?></textarea> </p> <p align="left"></td></tr><tr> <td height="" align="left"> </td> <td width="78%" align="left"><input type="submit" name="submit" value="Send" /> <input name="reset" type="reset" value="Reset" /></td></tr><tr> <td width="22%" height="104" align="left"> </td> <td align="left"><p> </p> <p> </p></td></tr></table></form>and mailfunctions.php<?function sendHTMLEmail($name, $email, $subject, $comments, $honoree, $recipient, $ip, $date, $time){ include("web2mail_config.php"); $recipient = "$yourname <$admin_email>"; $rand = md5(time()); $mime_boundary = "CJ Web2Mail V3.0_". $rand; $text_version = "Submitted: $date - $time\nFrom: $name - $email\n\n\n$honoree\n\n\n$comments\n\nIP: $ip\n\n\nPowered by CJ Web2Mail V3.0 © http://www.cj-design.com"; $html_version="<html>\n<head>\n<style>\nA:link {text-decoration: none; color: $alink_color;}\nA:visited {text-decoration: none; color: $vlink_color;}\nA:hover {font-style: normal; color: $hlink_color; text-decoration: underline;}\nBODY{font-family: $html_font; font-size: $html_font_size;}TD {font-family: $html_font; color: #000000; font-size: $html_font_size;}\n</style>\n</head>\n<body>\n\n<table border=\"0\" cellpadding=\"6\" cellspacing=\"0\" width=\"100%\">\n<tr>\n <td nowrap width=\"1%\">\n<b>Submitted</b>\n</td>\n<td width=\"99%\">$date - $time</td>\n</tr>\n<tr>\n<td nowrap width=\"1%\">\n<b>From</b></td>\n<td width=\"99%\">$name - <A HREF=\"mailto:$email\">$email</A></td>\n</tr>\n<tr>\n<td nowrap width=\"1%\" valign=\"top\">\n<b>Honoree</b>\n</td>\n<td width=\"99%\">$honoree</td></tr>\n<tr><td nowrap width=\"1%\" valign=\"top\">\n<b>Comments</b></td>\n<td width=\"99%\">".nl2br($comments)."</td>\n</tr>\n<tr>\n<td nowrap width=\"1%\"><b><small>IP Address</small></b></td>\n<td width=\"99%\"><small>$ip</small></td>\n</tr>\n</table><br>\n<br>\n<div align=\"right\"><i>Powered by <A HREF=\"http://www.cj-design.com\">CJ Web2Mail V3.0</A></i></div></body></html>"; $headers = "From: $name <$email>\r\n"; $headers .= "Reply-to: $email\r\n"; $headers .= "Return-Path: $email\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: multipart/alternative; charset=\"iso-8859-1\"; boundary=\"$mime_boundary\";\r\n\r\n"; // added ; before boundary $headers .= "This is a multi-part message in MIME format.\r\n\r\n"; $msg .= "--$mime_boundary\r\n"; $msg .= "Content-Type: text/plain; charset=\"iso-8859-1\"\r\n"; // deleted boundary $msg .= "Content-Transfer-Encoding: 8bit\r\n\r\n"; $msg .= $text_version."\r\n\r\n"; $msg .= "--$mime_boundary\r\n"; $msg .= "Content-Type: text/html; charset=\"iso-8859-1\"\r\n"; $msg .= "Content-Transfer-Encoding: 8bit\r\n\r\n"; $msg .= $html_version."\r\n\r\n"; $msg .= "--$mime_boundary--\r\n\r\n\r\n"; return mail($recipient, $subject, $msg, $headers);}function sendHTMLEmailAuto($name, $email, $subject){ include("web2mail_config.php"); $recipient = "$name <$email>"; $rand = md5(time()); $mime_boundary = "CJ Web2Mail V3.0_". $rand; $sub = "$auto_subject to $name"; $text_version = "$name, thank you for emailing $your_website.\n\nWe will get back to you soon concerning '$subject'.\n\nKind Regards\n$yourname\n\n\nNote: This is an automated response, please do not reply to this\n\n\nPowered by CJ Web2Mail V3.0 © http://www.cj-design.com"; $html_version = "<html>\n<head>\n<style>\nA:link {text-decoration: none; color: $alink_color;}\nA:visited {text-decoration: none; color: $vlink_color;}\nA:hover {font-style: normal; color: $hlink_color; text-decoration: underline;}\nBODY{font-family: $html_font; font-size: $html_font_size;}TD {font-family: $html_font; color: #000000; font-size: $html_font_size;}\n</style>\n</head>\n<body>\n\n<B>$name</B>, thank you for emailing $your_website.\n\n<br><br>We will get back to you soon concerning '<I><B>$subject</B></I>'.\n<br><br>\nKind Regards<br>\n$yourname<br>\n<br>\n<br>\n<small>Note: This is an automated response, please do not reply to this</small><br>\n<br><div align=\"right\"><i>Powered by <A HREF=\"http://www.cj-design.com\">CJ Web2Mail V3.0</A></i></div>"; $headers = "From: $your_website <$admin_email>\r\n"; $headers .= "Reply-to: $admin_email\r\n"; $headers .= "Return-Path: $admin_email\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: multipart/alternative; charset=\"iso-8859-1\"; boundary=\"$mime_boundary\";\r\n\r\n"; // added ; before boundary $headers .= "This is a multi-part message in MIME format.\r\n\r\n"; $msg .= "--$mime_boundary\r\n"; $msg .= "Content-Type: text/plain; charset=\"iso-8859-1\"\r\n"; // deleted boundary $msg .= "Content-Transfer-Encoding: 8bit\r\n\r\n"; $msg .= $text_version."\r\n\r\n"; $msg .= "--$mime_boundary\r\n"; $msg .= "Content-Type: text/html; charset=\"iso-8859-1\"\r\n"; $msg .= "Content-Transfer-Encoding: 8bit\r\n\r\n"; $msg .= $html_version."\r\n\r\n"; $msg .= "--$mime_boundary--\r\n\r\n\r\n"; $msg = stripslashes($msg); mail ($recipient, $sub, $msg, $headers);}function sendTextEmailAuto($name, $email, $subject){ include("web2mail_config.php"); $recipient = "$name <$email>"; $sub = "$auto_subject to $name"; $msg = "$name, thank you for emailing $your_website.\n\nWe will get back to you soon concerning '$subject'.\n\nKind Regards\n$yourname\n\n\nNote: This is an automated response, please do not reply to this\n\n\nPowered by CJ Web2Mail V3.0 © http://www.cj-design.com"; $headers = "From: $your_website <$admin_email>\r\nReply-To: $admin_email\r\n"; $msg = stripslashes($msg); mail ($recipient, $sub, $msg, $headers);}?>I hope this isn't too much to ask! Link to comment https://forums.phpfreaks.com/topic/26669-form-mail/ Share on other sites More sharing options...
littlejones Posted November 9, 2006 Share Posted November 9, 2006 Did data come through in the email for the other forms that you didn't modify, or is no data showing up in the email? Link to comment https://forums.phpfreaks.com/topic/26669-form-mail/#findComment-122004 Share on other sites More sharing options...
littlejones Posted November 9, 2006 Share Posted November 9, 2006 I notice that your forms action is set to $PHP_SELF yet there is no php or included php files in the form.php page? The code that handles the form seems to be in web2mail.php. Link to comment https://forums.phpfreaks.com/topic/26669-form-mail/#findComment-122005 Share on other sites More sharing options...
ttomnmo Posted November 9, 2006 Author Share Posted November 9, 2006 The email I am recieving look s like Submitted 11:21:33 pm - From dtuy - [email protected] Honoree Comments IP Address Wednesday 08 November 2006 I am getting the info provided by the form for the dateand time, for the name and email, and for the IP address. What i am not getting is the info input for the honoree and the comments on the form.I am new to php and trying to learn so I don't know what all the code means, but i think the web2mail.php handles the form and the mailfunction.php handles what becomes my email (along with some auto replies that are fine).Thanks for your help! Link to comment https://forums.phpfreaks.com/topic/26669-form-mail/#findComment-122137 Share on other sites More sharing options...
ttomnmo Posted November 9, 2006 Author Share Posted November 9, 2006 What I have done, and somewhere I went wrong, was change the input feilds in the form>php and also the <td align="left" width="78%"><input name="honoree" type="text" value="<? echo $_POST['honoree']; ?>" size="30"></td>Then in the web2mail.php I added the same variables and did for example $honoree = cleanUp($_POST['honoree']);Then on the mailfunction.php I added, at least I think I added, the $honoree to be included in the email both for text and html.$html_version="<html>\n<head>\n<style>\nA:link {text-decoration: none; color: $alink_color;}\nA:visited {text-decoration: none; color: $vlink_color;}\nA:hover {font-style: normal; color: $hlink_color; text-decoration: underline;}\nBODY{font-family: $html_font; font-size: $html_font_size;}TD {font-family: $html_font; color: #000000; font-size: $html_font_size;}\n</style>\n</head>\n<body>\n\n<table border=\"0\" cellpadding=\"6\" cellspacing=\"0\" width=\"100%\">\n<tr>\n <td nowrap width=\"1%\">\n<b>Submitted</b>\n</td>\n<td width=\"99%\">$date - $time</td>\n</tr>\n<tr>\n<td nowrap width=\"1%\">\n<b>From</b></td>\n<td width=\"99%\">$name - <A HREF=\"mailto:$email\">$email</A></td>\n</tr>\n<tr>\n<td nowrap width=\"1%\" valign=\"top\">\n<b>Honoree</b>\n</td>\n<td width=\"99%\">$honoree</td></tr>\n<tr><td nowrap width=\"1%\" valign=\"top\">\n<b>Comments</b></td>\n<td width=\"99%\">".nl2br($comments)."</td>\n</tr>\n<tr>\n<td nowrap width=\"1%\"><b><small>IP Address</small></b></td>\n<td width=\"99%\"><small>$ip</small></td>\n</tr>\n</table><br>\n<br>\n<div align=\"right\"><i>Powered by <A HREF=\"http://www.cj-design.com\">CJ Web2Mail V3.0</A></i></div></body></html>";Where am I going wrong? Link to comment https://forums.phpfreaks.com/topic/26669-form-mail/#findComment-122151 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.