beachdaze Posted January 24, 2007 Share Posted January 24, 2007 Code below worked in PHP4, but since the host upgraded to 5 it no longer works. The idea to take the submit from a form and have it email to admin and the user (if they entered an email - not required). The form still works to post to the db, just the email functions have stopped. Have there been changes to mail()?I don't have any error messages so I think the code it at least somewhat valid. I'm sure you need more info, if so please ask. Also, I have changed the server names and other info. Many thanks![code]// SEND EMAIL after sumbitting// return mail var is used in the auto response to submitter$returnemail = "admin.email.here";// This one has to be set. 1 EMAIL HERE ONLY - NOTE it is used in ini_set("sendmail_from",$primary_email);//check if submitted email is blankif (empty($x_email)){$primary_email = $returnemail;}else {$primary_email = $returnemail . "," . $x_email;}// What is the mail server of where this is hosted????$mailserver = "mail.server.here";// Set-up for PHP mail functionini_set("sendmail_from",$primary_email);ini_set("SMTP",$mailserver);$process_mailto = $primary_email;// -------------------- AUTO RESPOND - EMAIL - start// the email// if - start - (IF NOT BLANK - DO AUTO RESPOND)IF ($x_email != ""){$auto_mailto = $x_email;$auto_subject = "Prayer Vigil Confirmation";$auto_message1 = "Thank you, " . $x_name . " for your prayers.";$auto_message2 = "Name: " . $x_name;$auto_message2 .= "<BR>Email: " . $x_email;$auto_message2 .= "<BR>Time: " . $x_time;$auto_message2 .= "<BR>Location: " . $x_location;$auto_message .= $auto_message1 . "<BR><BR>";$auto_message .= $auto_message2;$auto_msg = ereg_replace("\\\'", "'", $auto_message);//$auto_msg = ereg_replace('\\\"', "\"", $auto_message);//mail($mailto, $subject, $msg);mail($process_mailto, $auto_subject, $auto_msg, "From: " . $returnemail . "\r\nReply-to: " . $returnemail . "\r\nContent-Type: text/html; charset=iso-8859-1\r\n");//mail($auto_mailto, $auto_subject, $auto_msg);} // if - end - (IF NOT BLANK - DO AUTO RESPOND)// -------------------- AUTO RESPOND - EMAIL - end[/code] Link to comment https://forums.phpfreaks.com/topic/35579-changes-in-mail-from-php-4-to-php5/ Share on other sites More sharing options...
trq Posted January 24, 2007 Share Posted January 24, 2007 There has been no changes in the mail function but yuo have a whole lot of undefined variables in there. Where are all these $x_* variables coming from? More than likely you have the old register globals issue. Register globals has long been off by default(good) in both php4 and php5, it looks like your trying to code as though they are on (bad). Link to comment https://forums.phpfreaks.com/topic/35579-changes-in-mail-from-php-4-to-php5/#findComment-168504 Share on other sites More sharing options...
beachdaze Posted January 24, 2007 Author Share Posted January 24, 2007 the $x vars are assigned earlier on the page, and they post fine. I didn't post the entire page to save space. As I said, this code worked fine last week. Now nothing. Thanks! Link to comment https://forums.phpfreaks.com/topic/35579-changes-in-mail-from-php-4-to-php5/#findComment-168507 Share on other sites More sharing options...
Caesar Posted January 24, 2007 Share Posted January 24, 2007 The register globals issue was my first guess as well. Any chance you can post the code preceding this? Link to comment https://forums.phpfreaks.com/topic/35579-changes-in-mail-from-php-4-to-php5/#findComment-168514 Share on other sites More sharing options...
beachdaze Posted January 24, 2007 Author Share Posted January 24, 2007 Here is the page...[code]<?PHP$thispagename = $_SERVER['PHP_SELF'];$x_flight = $_GET["flight"];$x_time = $_GET["time"];//echo "<SCRIPT>alert('" . $x_flight . "');</SCRIPT>";//get action$switchCMD = $_POST["switchCMD"];if (empty($switchCMD)){ $switchCMD = "A"; //set default content}?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HEAD><TITLE>Welcome to Florida Sonrise Chrysalis</TITLE><META http-equiv=Content-Type content="text/html; charset=windows-1252"><META content="" name=author><META content="" name=keywords><META content="" name=description><META http-equiv=/content-type content="text/html; charset=utf-8"><META content="MSHTML 6.00.2900.2838" name=GENERATOR><LINK HREF="stylesheet.css" type="text/css" rel="stylesheet"><!-- =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* --><!-- Includes - START --><SCRIPT language=JavaScript src="inc-mm_menu.js"></SCRIPT><SCRIPT language=JavaScript src="inc-js_extra.js"></SCRIPT><SCRIPT LANGUAGE="JavaScript" SRC="ew.js"></SCRIPT><!-- Includes - END --><!-- =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* --><SCRIPT LANGUAGE="JavaScript">function EW_checkMyForm(EW_this) {//----------------------------------------// NAME - Check - startif (!EW_hasValue(EW_this.name, "TEXT" )) {if (!EW_onError(EW_this, EW_this.name, "TEXT", "Please include your NAME."))return false; }// NAME - Check - end//----------------------------------------// EMAIL - Check - start/*// VARIFY FIELDif (!EW_hasValue(EW_this.email, "TEXT" )) {if (!EW_onError(EW_this, EW_this.email, "TEXT", "Please enter an EMAIL.")) {return false;}}// CHECK FIELD - VALIDATE EMAIL x_email (IF NOT BLANK)if (!EW_checkemail(EW_this.email.value)) { if (EW_this.email.value != "") { if (!EW_onError(EW_this, EW_this.email, "TEXT", "Please enter a valid EMAIL.")) {return false;} } }*/// EMAIL - Check - end//----------------------------------------//----------------------------------------return true;}</SCRIPT></HEAD><BODY><SCRIPT language=JavaScript1.2>mmLoadMenus();</SCRIPT><CENTER><!-- This is the main layout table --><TABLE cellSpacing=0 cellPadding=0 width=785 border=0> <TBODY> <TR> <TD colspan="3" background="images/banner_785x132_plain.jpg" height="132" width="785" border="0" align="right"><font color="white"><STRONG>Florida Sonrise Chrysalis    </BR>PO Box 731043    </BR>Ormond Beach, Florida 32173    </BR>[email protected]    </STRONG></font></TD> </TR> <TR> <TD width=11 background=images/side_left_11x9.jpg><IMG height=9 src="/images/spacer.gif" width=11 border=0></TD> <TD vAlign=top width=763><!-- mmMenuVDd - Table - START --> <TABLE borderColor=#255d80 cellSpacing=0 cellPadding=0 width="100%" border=1> <TBODY> <TR height=21> <TD vAlign=top align=right bgColor=#719ab6><FONT id=mmMenuVDd><A class=mmMenuVDdTop href="http://chrysalis.floridasonriseemmaus.com/start.htm">Home</A> | <A class=mmMenuVDdTop href="http://chrysalis.floridasonriseemmaus.com/about.htm">About</A> | <A class=mmMenuVDdTop id=link1 onmouseover="MM_showMenu(window.mm_menu_v_dd_003,-5,18,null,'link1')" onmouseout=MM_startTimeout(); href="http://chrysalis.floridasonriseemmaus.com/flights.htm" name=link1>Flights</A> | <A class=mmMenuVDdTop id=link2 onmouseover="MM_showMenu(window.mm_menu_v_dd_004,-5,18,null,'link2')" onmouseout=MM_startTimeout(); href="http://chrysalis.floridasonriseemmaus.com/pictures.htm" name=link2>Pictures</A> | <A class=mmMenuVDdTop href="http://chrysalis.floridasonriseemmaus.com/schedule.htm">Schedules</A> | <A class=mmMenuVDdTop href="http://chrysalis.floridasonriseemmaus.com/downloads.htm">Downloads</A> | <A class=mmMenuVDdTop href="http://chrysalis.floridasonriseemmaus.com/resources.htm">Resources</A> | <A class=mmMenuVDdTop href="http://chrysalis.floridasonriseemmaus.com/contact.htm">Contact Us</A> | <A class=mmMenuVDdTop href="http://chrysalis.floridasonriseemmaus.com/events/calendar.htm">Calendar</A> | <A class=mmMenuVDdTop href="http://chrysalis.floridasonriseemmaus.com/forum/index.php">Forum</A> </FONT></TD></TR></TBODY></TABLE><!-- mmMenuVDd - Table - END --> <TABLE cellSpacing=4 width="100%" border=0> <TBODY> <TR vAlign=top><!-- Main-Column - start --> <TD><!-- #*#*#*#*#*#*#*#*#* Content002 - START #*#*#*#*#*#*#*#*#* --> <TABLE cellSpacing=4 width="100%" border=0> <TBODY> <TR> <TD><!-- +++++++++++++++++++++++++++++++++++++++++++++++++++ --><!-- REPLACE THE "TITLE GOES HERE" BELOW WITH YOUR TEXT --> <P class=contentHeader>Prayer Vigil</P> <!-- THIS IS WHERE YOUR INFORMATION GOES USE WHATEVER SIZE AND TYPE OF TABLE YOU WANT --><?phpswitch ($switchCMD){//================================================case "A":?><!-- YOUR INFORMATION - start --><TABLE> <TBODY width="500" cellspacing="15" cellpadding="20"> <TR> <TD colspan = "3">Please enter your name, email address and location so we may update the printed lists. Only your name is required, but if you enter your email address we will send you an email with the time and date you sign up for! We would like to know where in the world you are so the butterflies will know that people around the world are praying for them.<br /> <B><I>Your email address will not be used for purpose other than to update our internal records. We will not sell, lease, or give your information to any other parties.</I></B></td> </TR> <TR> <TD colspan = "3"><HR></TD> </TR> <TR> <TD colspan = "3"> <!-- <FORM METHOD=POST ACTION=""> --> <FORM ONSUBMIT="return EW_checkMyForm(this);" ACTION="vigil.php" METHOD="post"> Name: <input type="text" name="name" size="30" maxlength="50" value="<?php echo $name; ?>"><I> Example - Joe Smith</I><br /> Email: <input type="text" name="email" size="30" maxlength="75"><I> Example - [email protected]</I><br /> Location: <input type="text" name="location" size="30" maxlength="75"><I> Example - Daytona Beach, FL or London, UK</I><br /> <input type="reset" name="reset" value="Clear Form"><input type="submit" name="action" value="Sign Up"> <input type="hidden" name="flight" value="<?php echo $x_flight; ?>"> <input type="hidden" name="time" value="<?php echo $x_time; ?>"> <input type="hidden" name="switchCMD" value="B"> </FORM> </TR> <TR> <TD colspan = "3"><HR></TD> </TR> </TBODY> </TABLE><!-- YOUR INFORMATION - end --><?phpbreak;//================================================case "B":ob_start();$x_id = $_POST["id"];$x_name = $_POST["name"];$x_email = $_POST["email"];$x_flight = $_POST["flight"];$x_time = $_POST["time"];$x_location = $_POST["location"];// INCLUDE - CONFIG FILE (functions & variables)include ("db.php");// ADD START// Open connection to the DB$tablename_001 = "`main`";$conn = mysql_connect (HOST, USER, PASS);mysql_select_db(DB);// Field ID$fieldList[] = "`id`";$theValue = (!get_magic_quotes_gpc()) ? addslashes($x_id) : $x_id;$theValue = ($theValue != "") ? " '" . $theValue . "'": "NULL";$valList[] = $theValue;// Field Name$fieldList[] = "`name`";$theValue = (!get_magic_quotes_gpc()) ? addslashes($x_name) : $x_name;$theValue = ($theValue != "") ? " '" . $theValue . "'": "NULL";$valList[] = $theValue;// Field Email$fieldList[] = "`email`";$theValue = (!get_magic_quotes_gpc()) ? addslashes($x_email) : $x_email;$theValue = ($theValue != "") ? " '" . $theValue . "'": "NULL";$valList[] = $theValue;// Field Flight$fieldList[] = "`flight`";$theValue = (!get_magic_quotes_gpc()) ? addslashes($x_flight) : $x_flight;$theValue = ($theValue != "") ? " '" . $theValue . "'": "NULL";$valList[] = $theValue;// Field Date/Time$fieldList[] = "`time`";$theValue = (!get_magic_quotes_gpc()) ? addslashes($x_time) : $x_time;$theValue = ($theValue != "") ? " '" . $theValue . "'": "NULL";$valList[] = $theValue;// Field Location$fieldList[] = "`location`";$theValue = (!get_magic_quotes_gpc()) ? addslashes($x_location) : $x_location;$theValue = ($theValue != "") ? " '" . $theValue . "'": "NULL";$valList[] = $theValue;// INSERT $insertSQL = "INSERT INTO" . $tablename_001 . " ("; for ($i = 0;$i < count($fieldList); $i++) { $insertSQL .=$fieldList[$i]; if ($i !=count($fieldList) -1) { $insertSQL .=","; }; }; $insertSQL .=") VALUES ("; for ($i = 0;$i < count($valList); $i++) { $insertSQL .= $valList[$i]; if ($i !=count($valList) -1) { $insertSQL .=","; }; }; $insertSQL .=")"; $rs = mysql_query($insertSQL, $conn) or die (mysql_error()); mysql_free_result($rs); mysql_close($conn); ob_end_clean();if (isset($_POST['submit'])) { global $dbc; if (ini_get('magic_quotes_gpc')) { $data = stripslahes($data); } return mysql_real_escape_string($data, $dbc);}$message = NULL;//===============================================// SEND EMAIL after sumbitting// return mail var is used in the auto response to submitter$returnemail = "[email protected]";// This one has to be set. 1 EMAIL HERE ONLY - NOTE it is used in ini_set("sendmail_from",$primary_email);//check if submitted email is blankif (empty($x_email)){$primary_email = $returnemail;}else {$primary_email = $returnemail . "," . $x_email;}// What is the mail server of where this is hosted????$mailserver = "mail.floridasonriseemmaus.com";// Set-up for PHP mail functionini_set("sendmail_from",$primary_email);ini_set("SMTP",$mailserver);$process_mailto = $primary_email;// -------------------- AUTO RESPOND - EMAIL - start// the email// if - start - (IF NOT BLANK - DO AUTO RESPOND)IF ($x_email != ""){$auto_mailto = $x_email;$auto_subject = "Prayer Vigil Confirmation";$auto_message1 = "Thank you, " . $x_name . " for your prayers.";$auto_message2 = "Name: " . $x_name;$auto_message2 .= "<BR>Email: " . $x_email;$auto_message2 .= "<BR>Time: " . $x_time;$auto_message2 .= "<BR>Location: " . $x_location;$auto_message .= $auto_message1 . "<BR><BR>";$auto_message .= $auto_message2;$auto_msg = ereg_replace("\\\'", "'", $auto_message);//$auto_msg = ereg_replace('\\\"', "\"", $auto_message);//mail($mailto, $subject, $msg);mail($process_mailto, $auto_subject, $auto_msg, "From: " . $returnemail . "\r\nReply-to: " . $returnemail . "\r\nContent-Type: text/html; charset=iso-8859-1\r\n");//mail($auto_mailto, $auto_subject, $auto_msg);} // if - end - (IF NOT BLANK - DO AUTO RESPOND)// -------------------- AUTO RESPOND - EMAIL - end//===============================================?><TABLE> <TBODY width="500" cellspacing="15" cellpadding="20"> <TR> <TD colspan = "3">Thank you for your prayers. Click <a href= "http://chrysalis.floridasonriseemmaus.com/flights.htm">here</A> to return to the flight page so you can choose another time, or <a href= "http://chrysalis.floridasonriseemmaus.com/start.htm">here</A> for the FSC home page.</td> </TR> </TBODY> </TABLE><?phpbreak;}?></TD></TR></TBODY></TABLE><!-- #*#*#*#*#*#*#*#*#* Content002 - END #*#*#*#*#*#*#*#*#* --></TD><!-- Main-Column - end --></TR></TBODY></TABLE><!-- #*#*#*#*#*#*#*#*#* Content001 - START #*#*#*#*#*#*#*#*#* --> <TABLE cellSpacing=8 cellPadding=3 width=100% border=0> <TBODY> <TR> <TD><!-- +++++++++++++++++++++++++++++++++++++++++++++++++++ --></TD></TR></TBODY></TABLE><!-- #*#*#*#*#*#*#*#*#* Content001 - END #*#*#*#*#*#*#*#*#* --><!-- end --></TD> <TD width=11 background=images/side_right_11x9.jpg><IMG height=9 src="/images/spacer.gif" width=11 border=0></TD></TR> <TR> <TD background=images/divider-a_785x3.jpg colSpan=3><IMG height=3 src="images/spacer.gif" width=785 border=0></TD></TR> <TR> <TD background=images/divider-b_785x3.jpg colSpan=3><IMG height=50 src="images/spacer.gif" width=785 border=0> </TD></TR> <TR> <TD colSpan=3><IMG height=18 src="images/footer_785x18.jpg" width=785 border=0></TD></TR></TBODY></TABLE></CENTER> </TABLE> </BODY></HTML>[/code] Link to comment https://forums.phpfreaks.com/topic/35579-changes-in-mail-from-php-4-to-php5/#findComment-168517 Share on other sites More sharing options...
Caesar Posted January 24, 2007 Share Posted January 24, 2007 It's also more than possible that the host has disabled the mail() function. ;) Link to comment https://forums.phpfreaks.com/topic/35579-changes-in-mail-from-php-4-to-php5/#findComment-168526 Share on other sites More sharing options...
beachdaze Posted January 26, 2007 Author Share Posted January 26, 2007 No idea why, but it the code now works. I didn't change anything, but I ain't complaining. Thanks! ;D Link to comment https://forums.phpfreaks.com/topic/35579-changes-in-mail-from-php-4-to-php5/#findComment-169809 Share on other sites More sharing options...
matfish Posted January 26, 2007 Share Posted January 26, 2007 Google PHPMailer ;) Link to comment https://forums.phpfreaks.com/topic/35579-changes-in-mail-from-php-4-to-php5/#findComment-169812 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.