Sydcomebak Posted March 31, 2009 Share Posted March 31, 2009 Can anyone explain to me how to make global variables show up in my output? I know I need to make them "Local," but I'm at a loss on how to do that exactly... <?php session_start(); if( $_SESSION['security_code'] == $_POST['security_code'] && !empty($_SESSION['security_code'] ) ) { $ipnumber = " $_SERVER[REMOTE_ADDR]"; // echo $ipnumber; /* emailer engine it assumes everything is already verified befire it gets it. */ $alpha="john"; $omega="1callservice.com"; //$alpha="gweber"; //$omega="midislandwatersports.com"; //$alpha="hbrelsford"; //$omega="1callservice.com"; $mail_from = "$alpha@$omega"; //$mail_toReceipt = $xxemail; $mail_to = "$alpha@$omega"; $mail_subject = "Online Reservation by <$xxname>"; //$mail_subjectReceipt = "Jadens Welcomes you to the 360 Event"; //$headers = "From: $mail_from\n"; //$headers .= "Content-Type:text/html; charset=iso-8859-1\n"; $headers = "From: Mid Island Water Sports<$mail_from>\n"; $headers .= "Content-Transfer-Encoding: 7bit\n"; $headers .= "Content-Type:text/html; charset=iso-8859-1\n"; // get contents of a file into a string $filename = "reservationbody.php"; $fd = fopen ($filename, "r"); $mail_body = fread ($fd, filesize ($filename)); fclose ($fd); // put variable values at correct place in form // sweep through and replace all variables //foreach($HTTP_SESSION_VARS as $key => $value) { // print "\$HTTP_SESSION_VARS[".$key."] = $value \n"; // $mail_body=str_replace($key,$value,$mail_body); //} $mail_body=str_replace(xxname,$xxname,$mail_body); $mail_body=str_replace(xxaddy,$xxaddy,$mail_body); $mail_body=str_replace(xxphone,$xxphone,$mail_body); $mail_body=str_replace(xxemail,$xxemail,$mail_body); $mail_body=str_replace(xxclass,$xxclass,$mail_body); $mail_body=str_replace(xxcheckbox1,$xxcheckbox1,$mail_body); $mail_body=str_replace(xxcheckbox2,$xxcheckbox2,$mail_body); $mail_body=str_replace(xxcheckbox3,$xxcheckbox3,$mail_body); $mail_body=str_replace(xxcheckbox4,$xxcheckbox4,$mail_body); $mail_body=str_replace(xxtravel,$xxtravel,$mail_body); $mail_body=str_replace(ipnumber,$ipnumber,$mail_body); //create different top messages $mail_bodyReceipttop=' <p align="left"><font face="Tahoma, Verdana, Arial" size="2">Dear '.$xxname.',<br><br> <br><br>This is the information we received from you:<br></font>'; $mail_bodytop=' <p align="left"><font face="Tahoma, Verdana, Arial" size="2"> The following contact information has been sent from the web site. <br></font>'; $mail_body_receipt=str_replace(xxheading,$mail_bodyReceipttop,$mail_body); $mail_body=str_replace(xxheading,$mail_bodytop,$mail_body); // split mail body dsc //$mail_body_receipt=$mail_body; //create different credit card entries - only last 4 digits for receipt $four=substr($xxccnum,-4); $receiptccnum=($four." - for security only the last four digits are shown"); //echo ('<br><br><br>test is '.$ccnum.' and itest is '.$iccnum.'<br><br><br>'); //echo ('<br><br><br>receipt is '.$receiptccnum.' and itest is '.$iccnum.'<br><br><br>'); $mail_body=str_replace(xxccnumber,$xxccnum,$mail_body); $mail_body_receipt=str_replace(xxccnumber,$receiptccnum,$mail_body_receipt); //diagnostic email display //echo $mail_body; //$mail_body = "the body"; //echo "$mail_to, $mail_subject, $mail_body, $headers<br>"; $status=(mail($mail_to, $mail_subject, $mail_body, $headers)); $thanks="Thank you for your interest in Mid Island Water Sports. We sell the fun you are looking for on vacation and will contact you shortly to confirm your reservation request.<br>We will require a credit card to hold reservations. <br><br> Thank you, <br><br> The Weber Family<br> MidIslandWaterSports.com "; unset($_SESSION['security_code']); } else { // Insert your code for showing an error message here $thanks="<b>The Varification Key Has been typed incorrectly, Please go back, REFRESH and try again.</b>"; } ?> <html> <head> <title>Mid Island Watersports-Fort Myers Beach Watersports and Dolphin Tours</title> <script type="text/javascript" language="JavaScript" src="specials.js"> </script> <style type="text/css"> A.white:link,A.white:visited{color:#ffffff;text-decoration:underline;font-family:verdana,arial;font-size:10px;} A.white:hover{color:#ffffff;text-decoration:none;font-family:verdana,arial;font-size:10px;} .style3 {color: #FFFFFF; font-size: 12px; } .style6 { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; } </style> </head> <body bgcolor="#003399" topmargin=0 leftmargin=0 marginheight=0 marginwidth=0> <div align="center"> <table border=0 cellpadding=0 cellspacing=0 width=650> <tr> <td align=left valign=middle colspan=2><img name="title" src="images/contact_title.jpg" width="650" height="135" border="0" usemap="#m_title" alt=""> <map name="m_title"> <area shape="rect" coords="521, 0, 650, 25" href="internetspecials.html" > </map></td> </tr> <tr bgcolor="#000000"> <td align=left valign=middle background="images/spacer.gif" width=650 height=15 bgcolor="#000000" colspan=2><font color="#ffffff" face="verdana,arial" size="1"> >> <a href="index2.html" class="white">Home</a> >> <a href="waverunners.html" class="white">Waverunners</a> >> <a href="parasailing.html" class="white">Parasailing</a> >> <a href="tours.html" class="white">Dolphin Tours</a> >> <a href="reviews.html" class="white">Read Our Reviews</a> >> </font></td> </tr> <tr> <td align=center valign=top background="images/form_back.jpg" width=650 height=410><br> <font color="#000000" size="2" face="verdana,arial"> <strong> <div align=left></div> <br> <br> <table border=0 cellpadding=0 cellspacing=0 width=600> <tr> <td align=center valign=top> </td> </tr> </table> <?php echo $thanks; ?> <table border=0 cellpadding=0 cellspacing=0 width=600> <tr> </tr> </table> <table border=0 cellpadding=0 cellspacing=0 width=600> </table> <table border=0 cellpadding=0 cellspacing=0 width=600> </table> </strong></font> </tr> <tr> <td align=center valign=middle colspan=2> </td> </tr> <tr> <td align=center valign=middle bgcolor="#336699" colspan=2><img width=650 src="images/bottom_line.gif"></td> </tr> <tr> <td bgcolor="#000099" align=right background="images/spacer.gif" height=15 width=650 colspan=2><span class="style3">Sandpiper Gulf Resort 5550 ESTERO BLVD. ~ FORT MYERS BEACH, FL 33931 ~ 239-765-0965<br> Holiday Inn Location 6890 ESTERO BLVD. ~ FORT MYERS BEACH, FL 33931 ~ 239-707-2901</span></td> </tr> </table> </div> </body> </html> I appreciate any pointers, and in no way expect someone to re-write all of that. Thanks! -Dave in Dallas Quote Link to comment https://forums.phpfreaks.com/topic/151957-my-admin-has-decided-to-disable-server-global-variables-bye-bye-email-form/ Share on other sites More sharing options...
DanielHardy Posted March 31, 2009 Share Posted March 31, 2009 Just identify the globals in your code and google the available replacements for each Quote Link to comment https://forums.phpfreaks.com/topic/151957-my-admin-has-decided-to-disable-server-global-variables-bye-bye-email-form/#findComment-797990 Share on other sites More sharing options...
Sydcomebak Posted March 31, 2009 Author Share Posted March 31, 2009 Daniel, I'm sorry, I don't understand. Quote Link to comment https://forums.phpfreaks.com/topic/151957-my-admin-has-decided-to-disable-server-global-variables-bye-bye-email-form/#findComment-798071 Share on other sites More sharing options...
premiso Posted March 31, 2009 Share Posted March 31, 2009 To elaborate, since you did not post your form, this is kind of difficult. Are the values you want to replace in the body coming from the form? If so, this may work: //foreach($HTTP_SESSION_VARS as $key => $value) { // print "\$HTTP_SESSION_VARS[".$key."] = $value \n"; // $mail_body=str_replace($key,$value,$mail_body); //} foreach ($_POST as $key => $val) { $mail_body=str_replace($key,$val,$mail_body); } $mail_body=str_replace("ipnumber",$ipnumber,$mail_body); // use quotes around items like that, leaving them off causes an undefined constant notice. Basically when you were defining the $mail_body and doing the replaces, you were using $formitem instead of $_POST['formitem']. For POST and GET data sent from URL/FORMS you should access them via $_POST or $_GET from now on, as the other will not work anymore. Quote Link to comment https://forums.phpfreaks.com/topic/151957-my-admin-has-decided-to-disable-server-global-variables-bye-bye-email-form/#findComment-798137 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.