mdeppa Posted December 31, 2012 Share Posted December 31, 2012 Hello this is my first time here and was looking for some help for our businesses website. I am a novice at PHP coding, I was able to create a PHP code through an online tutorial, see attached. I created a form in Dreamweaver that points to the PHP code to send me an e-mail with the information. The tutorial worked great. I was on Unix platform with Network Solutions. I have just switched hosting providers to 1and1 which is a Linux platform. The code I created has worked perfect when I was with Network Solutions. Now it is acting up on 1and1s. It processes the code correctly, and takes you to the confirmation page. I get an e-mail, but it has no information in it. The e-mail contains all the tag headlines/topics I have it programmed to do, but it wont send the information that is inputed by the user. So I just get a blank email with no information from the user. I don't know what is different. I don't know if teh Linux vs Unix has anything to do with it. I would assume the coding would work on both. Any help would be greatly appreciated! This has a popular section of my website down. Thanks for all your help. Michael datesd.php Quote Link to comment https://forums.phpfreaks.com/topic/272534-php-code-not-working-after-hosting-transfer/ Share on other sites More sharing options...
BrettHartel Posted December 31, 2012 Share Posted December 31, 2012 Please post your php code between the [code] [/code] tags. Nobody wants to download random files from the internet. Quote Link to comment https://forums.phpfreaks.com/topic/272534-php-code-not-working-after-hosting-transfer/#findComment-1402285 Share on other sites More sharing options...
mdeppa Posted December 31, 2012 Author Share Posted December 31, 2012 (edited) <?php /* Subject and E-Mail Variables */ $emailSubject = 'Date and Location Request'; $webMaster = [email="'michael@accidentavoidanceworkshops.org'"]'michael@accidentavoidanceworkshops.org'[/email]; /* Gather Data Variables */ $studentsnameField = $_POST['studentsname']; $highschoolField = $_POST['highschool']; $parentsnameField = $_POST['parentsname']; $cityField = $_POST['city']; $stateField = $_POST['state']; $hearField = $_POST['hear']; $dayphoneField = $_POST['dayphone']; $emailField = $_POST['email']; $body = <<<EOD <br><hr><br> <b>Students Name:</b> $studentsname <br> <b>Nearest High School:</b> $highschool <br> <b>Parents Name:</b> $parentsname <br> <b>How did you hear about the Workshops?:</b> $hear <br> <b>City:</b> $city <br> <b>State:</b> $state <br> <b>Daytime Phone:</b> $dayphone <br> <b>E-Mail:</b> $email <br> EOD; $headers = "From: $email\r\n"; $headers .= "Content-type: text/html\r\n"; $success = mail($webMaster, $emailSubject, $body, $headers); var_dump($success); /* Results rendered as html */ $theResults = <<<EOD <html xmlns="[url="http://www.w3.org/1999/xhtml"]http://www.w3.org/1999/xhtml[/url]"><!-- InstanceBegin template="/Templates/pagesb.dwt" codeOutsideHTMLIsLocked="false" --> <link rel="icon" type="image/png" href="/images/myicon.png" /> <script src="Scripts/swfobject_modified.js" type="text/javascript"></script> <script type="text/javascript"> <!-- function MM_swapImgRestore() { //v3.0 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc; } function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} } function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x && d.getElementById) x=d.getElementById(n); return x; } function MM_swapImage() { //v3.0 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3) if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];} } //--> </script> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <!-- InstanceBeginEditable name="doctitle" --> <title>Untitled Document</title> <!-- InstanceEndEditable --> <style type="text/css"> <!-- body { background-color: #000; background-image: url(templatefiles/bg.jpg); background-repeat: no-repeat; background-attachment: fixed; background-position: center; background-position: top; margin-top: 0px; margin-bottom: 0px; text-align: left; } --> </style><link href="style.css" rel="stylesheet" type="text/css" /><style type="text/css"> <!-- @import url("style.css"); a:link { color: #FFF; text-decoration: none; } a:visited { text-decoration: none; color: #FFF; } a:hover { text-decoration: none; color: #F00; } a:active { text-decoration: none; } --> </style> <!-- InstanceBeginEditable name="head" --> <!-- InstanceEndEditable --> <meta name="Keywords" content="Teen driving, defensive driving, drivers ed, driver’s ed, driver’s education, drivers education, car control, car control clinic, new driver car control clinic, street survival, fear this, bob Bondurant, skip barber, crash avoidance, active defensive driving, level 6 defensive driving, advanced driver training, advanced teen driver training, advanced driver education, accident avoidance, crash avoidance, crash prevention, crash training, drivers test, road test, aarp, elderly driving course, national defensive driving institute" /> <script language="Javascript" src="[url="https://seal.networksolutions.com/siteseal/javascript/siteseal.js"]https://seal.networksolutions.com/siteseal/javascript/siteseal.js[/url]" type="text/javascript"></script> </head> <body onload="MM_preloadImages('templatefiles/buttonbar_course_two.png','templatefiles/buttonbar_dates_two.png','templatefiles/buttonbar_testimonials_two.png','templatefiles/buttonbar_fundraiser_two.png','templatefiles/buttonbar_fleet_two.png','templatefiles/buttonbar_goals_two.png')"><meta name="description" content="Accident Avoidance Workshops. 770-970-0571. The Ultimate, Revolutionary Program in Defensive Driving!" /> <div align="center"> <table width="958" border="0" cellspacing="0" cellpadding="0" background="templatefiles/tablebgrd.jpg"> <tr> <td align="center"><table width="940" border="0" cellspacing="0" cellpadding="0"> <tr> <td><object id="FlashID" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="940" height="227"> <param name="movie" value="swf/headerc.swf" /> <param name="quality" value="high" /> <param name="wmode" value="opaque" /> <param name="swfversion" value="7.0.70.0" /> <!-- This param tag prompts users with Flash Player 6.0 r65 and higher to download the latest version of Flash Player. Delete it if you don’t want users to see the prompt. --> <param name="expressinstall" value="Scripts/expressInstall.swf" /> <!-- Next object tag is for non-IE browsers. So hide it from IE using IECC. --> <!--[if !IE]>--> <object type="application/x-shockwave-flash" data="swf/headerc.swf" width="940" height="227"> <!--<![endif]--> <param name="quality" value="high" /> <param name="wmode" value="opaque" /> <param name="swfversion" value="7.0.70.0" /> <param name="expressinstall" value="Scripts/expressInstall.swf" /> <!-- The browser displays the following alternative content for users with Flash Player 6.0 and older. --> <div> <h4>Content on this page requires a newer version of Adobe Flash Player.</h4> <p><a href="[url="http://www.adobe.com/go/getflashplayer"><img"http://www.adobe.com/go/getflashplayer"><img/a%20src="a%20href="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif"http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif/a"]https://www.accidentavoidanceworkshops.org/register.html">Register</a><br[/url] /> <a href="supporters.html">Supporters</a><br /> <a href="multimedia.html">Multimedia</a><br /> <a href="about.html">About</a><br /> <a href="staff.html">Staff</a><br /> Press Images</td> </tr> </table></td> <td width="365" valign="top"><table width="150" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="20" align="left" valign="top" class="footer_red_heading">Contact</td> </tr> <tr> <td height="40" valign="top" class="footer_main_text">Phone: (770) 971-0571<br /> <a href="[email="info@accidentavoidanceworkshops.org">Info@AccidentAvoidanceWorkshops.org</a></td"info@accidentavoidanceworkshops.org">Info@AccidentAvoidanceWorkshops.org</a></td/a> %20%20%20%20</tr> %20%20%20%20<tr> %20%20<td%20class="footer_main_text">Follow%20Us%20On:%20<a%20href="a%20href="http://www.facebook.com/AccidentAvoidanceWorkshops"><img"]http://www.facebook.com/AccidentAvoidanceWorkshops"><img[/email] src="templatefiles/facebookfooter.png" width="24" height="24" border="0" /></a> <a href="[url="http://accidentavoidanceworkshops.blogspot.com/"><img"http://accidentavoidanceworkshops.blogspot.com/"><img/a%20src="templatefiles/bloggerfooter.png"]http://www.youtube.com/user/accidentAvoidance"><img[/url] src="templatefiles/youtubefooter.png" width="24" height="24" border="0" /></a></td> </tr> </table></td> <td width="105" class="footer_nddi_main">Accident Avoidance<br /> Workshops<br /> is certified by the<br /> National Defensive<br /> Driving Institute</td> <td width="105" align="right"><img src="images/nddi_aaw_cert.png" width="104" height="104" /></td> <td width="15"> </td> </tr> <tr> <td> </td> <td height="30" colspan="5" align="center" valign="bottom" class="footer_main_text"><font size="-2"><div align="center">All tuitions may be transferred or cancelled all the way up to the billing date. At that point, all resources, materials and insurance will be ordered for your student<br /> based on your committed attendance and therefore, your tuition will not be refundable or transferable after the billing date.</div></font></td> <td> </td> </tr> </table></td> </tr> </table></td> </tr> </table> </div> <script type="text/javascript"> <!-- swfobject.registerObject("FlashID"); //--> </script> </body> <!-- InstanceEnd --></html> EOD; echo "$theResults"; ?> Sorry about that. I have it posted above. Thanks for all your help! Edited December 31, 2012 by mdeppa Quote Link to comment https://forums.phpfreaks.com/topic/272534-php-code-not-working-after-hosting-transfer/#findComment-1402332 Share on other sites More sharing options...
Muddy_Funster Posted December 31, 2012 Share Posted December 31, 2012 could you post up your form code aswell please? Quote Link to comment https://forums.phpfreaks.com/topic/272534-php-code-not-working-after-hosting-transfer/#findComment-1402334 Share on other sites More sharing options...
mdeppa Posted December 31, 2012 Author Share Posted December 31, 2012 Thank you for the reply. The E-mail tag at the begining of the PHP code for some reason won't let me correct the e-mail formating from the forum. Here is the code for the form the is in the html page: <form action="datesd.php" method="post" name="dates" target="_self" id="dates"> <label for="studentsname"><span class="formtitles">Students Name:</span> </label> <span id="sprytextfield1"> <input name="studentsname" type="text" id="studentsname" size="30" /> <span class="textfieldRequiredMsg">A value is required.</span></span><br /><br /><label for="highschool"><span class="formtitles">Nearest High School:</span> </label> <span id="sprytextfield4"> <input name="highschool" type="text" id="highschool" size="30" /> <span class="textfieldRequiredMsg">A value is required.</span></span><br><br /> <label for="parentsname"><span class="formtitles">Coach/Parents Name:</span> </label> <span id="sprytextfield2"> <input name="parentsname" type="text" id="parentsname" value="" size="30" /> <span class="textfieldRequiredMsg">A value is required.</span></span><br /><br /> <label for="city"><span class="formtitles">City:</span> </label> <span id="sprytextfield3"> <input name="city" type="text" id="city" size="30" /> <span class="textfieldRequiredMsg">A value is required.</span></span> <label for="state" class="formtitles">State</label> <span id="sprytextfield9"> <input name="state" type="text" id="state" size="5" maxlength="2" /> <span class="textfieldRequiredMsg">A value is required.</span></span><br /> <br /> <label for="hear"><span class="formtitles">How did you hear about the Accident Avoidance Workshops?:</span></label><br /> <span id="sprytextfield5"> <input name="hear" type="text" id="hear" size="40" /> <span class="textfieldRequiredMsg">A value is required.</span></span><br /><br /> <label for="dayphone"><span class="formtitles">Daytime Phone Number:</span> </label> <span id="sprytextfield6"> <input name="dayphone" type="text" id="dayphone" size="30" /> <span class="textfieldRequiredMsg">A value is required.</span></span><br /><br /> <label for="email"><span class="formtitles">E-Mail Address:</span> </label> <span id="sprytextfield8"> <input name="email" type="text" id="email" size="30" /> <span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span><br /><br /> <label> <input name="submit" type="submit" id="submit" value="Submit" /> </label> <label> <input type="reset" name="reset" id="reset" value="Reset" /> </label> </form> Thanks, Michael Quote Link to comment https://forums.phpfreaks.com/topic/272534-php-code-not-working-after-hosting-transfer/#findComment-1402338 Share on other sites More sharing options...
Muddy_Funster Posted December 31, 2012 Share Posted December 31, 2012 am I right to assume that the first page you posted is in the same directory as the form page and is called datesd.php (case sensitive accuracy)? Quote Link to comment https://forums.phpfreaks.com/topic/272534-php-code-not-working-after-hosting-transfer/#findComment-1402345 Share on other sites More sharing options...
mdeppa Posted December 31, 2012 Author Share Posted December 31, 2012 Correct the first code is datesd.php and it is located in the same directory as the html file. They are actually both in the root drectory. I would think the code would work no problem after the hosting transfer. Thanks for your help! Quote Link to comment https://forums.phpfreaks.com/topic/272534-php-code-not-working-after-hosting-transfer/#findComment-1402349 Share on other sites More sharing options...
jcbones Posted December 31, 2012 Share Posted December 31, 2012 The problem is the user data submitted by the form, so we need to see what the datesd.php page is getting from the form page. So add this to the top of your datesd.php page. <?php //DEBUGGING echo '<pre>' . print_r($_POST,true) . '</pre>'; Quote Link to comment https://forums.phpfreaks.com/topic/272534-php-code-not-working-after-hosting-transfer/#findComment-1402351 Share on other sites More sharing options...
jcbones Posted December 31, 2012 Share Posted December 31, 2012 On second look, I see the problem. /* Gather Data Variables */ $studentsnameField = $_POST['studentsname']; $highschoolField = $_POST['highschool']; $parentsnameField = $_POST['parentsname']; $cityField = $_POST['city']; $stateField = $_POST['state']; $hearField = $_POST['hear']; $dayphoneField = $_POST['dayphone']; $emailField = $_POST['email']; $body = <<<EOD <br><hr><br> <b>Students Name:</b> $studentsname <br> <b>Nearest High School:</b> $highschool <br> <b>Parents Name:</b> $parentsname <br> <b>How did you hear about the Workshops?:</b> $hear <br> <b>City:</b> $city <br> <b>State:</b> $state <br> <b>Daytime Phone:</b> $dayphone <br> <b>E-Mail:</b> $email <br> EOD; Your variable names under /*Gather Data*/ doesn't match your variable names under $body. Quote Link to comment https://forums.phpfreaks.com/topic/272534-php-code-not-working-after-hosting-transfer/#findComment-1402354 Share on other sites More sharing options...
Muddy_Funster Posted December 31, 2012 Share Posted December 31, 2012 do you get anything back if you do a var_dump($_POST); ? Quote Link to comment https://forums.phpfreaks.com/topic/272534-php-code-not-working-after-hosting-transfer/#findComment-1402355 Share on other sites More sharing options...
mdeppa Posted December 31, 2012 Author Share Posted December 31, 2012 I tried changing the var_dump($_POST); it sends an e-mail but does not have any input data. Before it goes to the confirmation page it flashes a white page with some coding on it real quick and then sends you to the confirmation page. jcbones, I ran the debugging code and this is what I get at the top of the confirmation page: Array ( [studentsname] => Test [highschool] => Test [parentsname] => Test [city] => Test [state] => AA [hear] => Test [dayphone] => 777-888-9999 [email] => mdd1127@yahoo.com [submit] => Submit ) array(9) { ["studentsname"]=> string(4) "Test" ["highschool"]=> string(4) "Test" ["parentsname"]=> string(4) "Test" ["city"]=> string(4) "Test" ["state"]=> string(2) "AA" ["hear"]=> string(4) "Test" ["dayphone"]=> string(12) "777-888-9999" ["email"]=> string(17) "mdd1127@yahoo.com" ["submit"]=> string(6) "Submit" } You mentioned something about the variable names not matching. I am not quite sure I see what is off? Do I need to include the ' ' ? Thank you both so much for your help Quote Link to comment https://forums.phpfreaks.com/topic/272534-php-code-not-working-after-hosting-transfer/#findComment-1402362 Share on other sites More sharing options...
mdeppa Posted December 31, 2012 Author Share Posted December 31, 2012 I change teh var_dump back to var_dump($success); and ran the debug this is what the code comes back as: Array ( [studentsname] => Test [highschool] => Test [parentsname] => Test [city] => Test [state] => TT [hear] => Test [dayphone] => 777-888-9999 [email] => mdd1127@yahoo.com [submit] => Submit ) bool(true) Quote Link to comment https://forums.phpfreaks.com/topic/272534-php-code-not-working-after-hosting-transfer/#findComment-1402365 Share on other sites More sharing options...
Muddy_Funster Posted December 31, 2012 Share Posted December 31, 2012 as JCBones said, your variable names are out of sync, take the Field off the end of each of the variables that you assigning from the post array in the Gather Data Variables section Quote Link to comment https://forums.phpfreaks.com/topic/272534-php-code-not-working-after-hosting-transfer/#findComment-1402366 Share on other sites More sharing options...
mdeppa Posted December 31, 2012 Author Share Posted December 31, 2012 SUCCESS!!!! That was all it was! That is intersting how it worked on a different hosting package and not on another. Thank you both for your help, I really appreciate it. Quote Link to comment https://forums.phpfreaks.com/topic/272534-php-code-not-working-after-hosting-transfer/#findComment-1402370 Share on other sites More sharing options...
Muddy_Funster Posted December 31, 2012 Share Posted December 31, 2012 it was JCBones that spoted it, the credit's his/hers. I am suprised that it worked at all with the missnamed variables....but hell, anythings possible with dreamweaver. Quote Link to comment https://forums.phpfreaks.com/topic/272534-php-code-not-working-after-hosting-transfer/#findComment-1402372 Share on other sites More sharing options...
PFMaBiSmAd Posted December 31, 2012 Share Posted December 31, 2012 Your code worked on your original hosting because register_globals were on and the php program variables ($studentsname, ... ) being used in the $body that matched the $_POST index names were magically being created. The lines of code setting the variables with Field on the end of them ($studentsnameField, ...) were just taking up space in the code and weren't setting variables with names that were being used in the $body variable. On your new hosting register_globals are off, or even completely removed (they were depreciated and turned off over 10 years ago, and were removed as of php5.4) and there needs to be lines of code like - $studentsname = $_POST['studentsname']; to get your code to work. Quote Link to comment https://forums.phpfreaks.com/topic/272534-php-code-not-working-after-hosting-transfer/#findComment-1402373 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.