fatmikey Posted February 17, 2009 Share Posted February 17, 2009 Hi, I have this PHP script below, that works for the most part except for a few areas and I need some help from you guys to tell me where it's broken. So, the script works but it doesn't: 1)send emails to two accounts 2)do proper error checking 3)write to data flat file like it's supposed to Here's the URL of the live test site where this file is hosted: https://www.ottawapolefitness.com/test/test.php Here's the code: <?php if ($_POST){ // get posted data into local variables $Email = Trim(stripslashes($_POST['Email'])); $To = "[email protected]"; $FirstName = ucwords(Trim(stripslashes($_POST['FirstName']))); $LastName = ucwords(Trim(stripslashes($_POST['LastName']))); $Bname = $Firstname . " " . $Lastname; $Telephone = Trim(stripslashes($_POST['Telephone'])); $Phone = $Telephone; $Address = Trim(stripslashes($_POST['Address'])); $Baddress1 = $Address; $City = Trim(stripslashes($_POST['City'])); $Bcity = $City; $Province = ($_POST['Province']); $Bprovince = $Province; $PostalCode = strtoupper(Trim(stripslashes($_POST['PostalCode']))); $PostalCode = ereg_replace("[^A-Za-z0-9]", "", $PostalCode); $PostalCode = substr($PostalCode,0,3) . substr($PostalCode,3,3); $Bpostalcode = PostalCode; $Bcountry = "Canada"; $Class = ($_POST['Class']); $Subject = "Registration for " . $Class; $Subject2 = "Registration Confirmation"; $Date = ($_POST['Date']); $Time = Trim(stripslashes($_POST['Time'])); $How = Trim(stripslashes($_POST['How'])); $Comments = Trim(stripslashes($_POST['Comments'])); $Headers = "From: " . $FirstName . " " . $LastName . " <" . $Email . ">"; $Headers2 = "From: " . "Ottawa Pole Fitness <[email protected]>"; $Daytime = time (); $File = "./meth/reglog.csv"; // validation $validationOK=true; if (Trim($FirstName)=="") {$error = $error."Your name is empty<br>";} if (Trim($LastName)=="") {$error = $error."Your last name is empty<br>";} if (Trim($Email)=="") {$error = $error."Your email is empty<br>";}else{ if (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $Email)) {$error = $error."Your email is invalid<br>";}} if (strlen($Telephone) < 10) {$error = $error."Your telephone is empty<br>";} if (!$validationOK) {$error = $error."Please check the box!<br>";} if ($error == ""){ // This code will strip out any commas and replace them with a space for the address and comments fields. function commasplit ($name) { $v1 = explode (",", $name) ; $name = "" ; foreach ($v1 as $t) { $name .= $t ; } return $name ; } $Address = commasplit($Address) ; $Comments = commasplit($Comments) ; // This code will format the telephone number of 555-555-5555 function phone_number($sPhone){ $sPhone = ereg_replace("[^0-9]",'',$sPhone); if(strlen($sPhone) != 10) return(False); $sArea = substr($sPhone,0,3); $sPrefix = substr($sPhone,3,3); $sNumber = substr($sPhone,6,4); $sPhone = $sArea."-".$sPrefix."-".$sNumber; return($sPhone); } $Telephone = phone_number($Telephone); // prepare email body text $Body = ""; $Body .= "Date: "; $Body .= date("d/m/Y",$Daytime); $Body .= "\n"; $Body .= "Time: "; $Body .= date("H:i",$Daytime); $Body .= "\n"; $Body .= "Name: " . $FirstName . " " . $LastName . "\n"; $Body .= "Telephone: "; $Body .= $Telephone; $Body .= "\n"; $Body .= "Email: "; $Body .= $Email; $Body .= "\n"; $Body .= "Address: "; $Body .= $Address; $Body .= "\n"; $Body .= "City: "; $Body .= $City; $Body .= "\n"; $Body .= "Province: "; $Body .= $Province; $Body .= "\n"; $Body .= "PostalCode: "; $Body .= $PostalCode; $Body .= "\n"; $Body .= "Class: "; $Body .= $Class; $Body .= "\n"; $Body .= "How: "; $Body .= $How; $Body .= "\n"; $Body .= "Comments: "; $Body .= $Comments; $Body .= "\n"; // prepare email body text for confirmation $Msg = "Hi " . $FirstName . ","; $Msg .= "\n"; $Msg .= "\n"; $Msg .= "Thank you for registering with Ottawa Pole Fitness. "; $Msg .= "A spot has now been confirmed for you to take a class. "; $Msg .= "You have selected " . $Class . ". "; $Msg .= "Remember to download complete a waiver http://ottawapolefitness.com/docs/Waiver.pdf "; $Msg .= "and bring it with you to your first class along with your payment. "; $Msg .= "We only accept cash or cheque payable to Ottawa Pole Fitness Inc. GST is included in all our prices. "; $Msg .= "We are located at 1066 Somerset St. W. at the intersection of Bayswater St. suite B-101 in the lower level. "; $Msg .= "Just take the elevator down one level. Be sure to bring a Yoga mat to class and "; $Msg .= "please arrive 5-10 minutes early to process your registration and payment."; $Msg .= "\n"; $Msg .= "\n"; $Msg .= "I look forward to seeing you and have a great day!"; $Msg .= "\n"; $Msg .= "\n"; $Msg .= "Li Hewitt"; $Msg .= "\n"; $Msg .= "613-371-3342"; $Msg .= "\n"; $Msg .= "www.ottawapolefitness.com"; $Msg .= "\n"; $Msg .= "\n"; $Msg .= "[this is an automated confirmation email generated on " . date("d/m/Y",$Daytime) . "]"; // record registrations to a file $Handle = fopen($File, 'a'); $Data = date("d/m/Y",$Daytime) . ","; $Data .= date("H:i",$Daytime) . ","; $Data .= $FirstName . ","; $Data .= $LastName . ","; $Data .= $Telephone . ","; $Data .= $Email . ","; $Data .= $Address . ","; $Data .= $City . ","; $Data .= $Province . ","; $Data .= $PostalCode . ","; $Data .= $Class . ","; $Data .= $How . "\n"; fwrite($Handle, $Data); fclose($Handle); if (mail($To, $Subject, $Body, $Headers)) { print "<meta http-equiv=\"refresh\" content=\"0;URL=thankyou.htm\">"; } else { $error = $error."There has been an error sending out your data!<br>"; mail($Email, $Subject2, $Msg, $Headers2); } } } // The form function form($error){ print (' <form action="https://devcheckout.psigate.com/HTMLPost/HTMLMessenger" method="POST" name="regform" id="regform">'); if ($error!=""){ print (' <table width="505" border="0" align="center"> <tr class="font-norm-grey"> <td width="491">'.$error.'</td> </tr> </table>'); } print (' <table width="505" border="0" align="center"> <INPUT TYPE=HIDDEN NAME="MerchantID" VALUE="psigatecapturescard001010"> <INPUT TYPE=HIDDEN NAME="CustomerRefNo" VALUE="123456789"> <INPUT TYPE=HIDDEN NAME="PaymentType" VALUE="CC"> <INPUT TYPE=HIDDEN NAME="TestResult" VALUE=""> <INPUT TYPE=HIDDEN NAME="OrderID" VALUE=""> <INPUT TYPE=HIDDEN NAME="UserID" VALUE="User1"> <INPUT TYPE=HIDDEN NAME="SubTotal" VALUE="28.57"> <INPUT TYPE=HIDDEN NAME="Tax1" VALUE="1.43"> <INPUT TYPE=HIDDEN NAME="SubTotal" VALUE="28.57"> <INPUT TYPE=HIDDEN NAME="ItemID01" VALUE="Pole Dancing Lessons"> <INPUT TYPE=HIDDEN NAME="Description01" VALUE="Deposit for Pole Dancing Class"> <INPUT TYPE=HIDDEN NAME="Quantity01" VALUE="1"> <INPUT TYPE=HIDDEN NAME="Price01" VALUE="28.57"> <table width="517" border="0" align="center" cellpadding="0" cellspacing="0"> <tr bordercolor="#000000"> <td width="200" class="font-norm-grey"> <div align="right">First Name:</div></td> <td width="10"> </td> <td width="309"> <input name="fname" type="text" id="FirstName" size="25"></td> </tr> <tr bordercolor="#000000"> <td class="font-norm-grey"> <div align="right">Last Name:</div></td> <td width="10"> </td> <td> <input name="lname" type="text" id="LastName" size="25"></td> </tr> <tr bordercolor="#000000"> <td class="font-norm-grey"> <div align="right">Telephone:</div></td> <td width="10"> </td> <td> <input name="tel" type="text" id="Telephone" size="12"></td> </tr> <tr bordercolor="#000000"> <td height="24" class="font-norm-grey"> <div align="right">E-mail address: </div></td> <td width="10"> </td> <td> <input name="email" type="text" id="Email" size="25"></td> </tr> <tr bordercolor="#000000"> <td class="font-norm-grey"> <div align="right">Address:</div></td> <td width="10"> </td> <td> <input name="address" type="text" id="Address" size="50"></td> </tr> <tr bordercolor="#000000"> <td class="font-norm-grey"> <div align="right">Province:</div></td> <td width="10"> </td> <td> <select name="prov" size="1" id="select4"> <option>Ontario</option> <option>Quebec</option> </select></td> </tr> <tr bordercolor="#000000"> <td class="font-norm-grey"> <div align="right">City:</div></td> <td width="10"> </td> <td> <input name="city" type="text" id="City" value="Ottawa" size="20"></td> </tr> <tr bordercolor="#000000"> <td class="font-norm-grey"> <div align="right">Postal Code:</div></td> <td width="10"> </td> <td> <input name="pcode" type="text" id="PostalCode" size="10"></td> </tr> <tr bordercolor="#000000"> <td class="font-norm-grey"> <div align="right">Country:</div></td> <td width="10"> </td> <td> <input name="country" type="text" id="Bcountry" value="Canada" size="15"></td> </tr> <tr> <td height="15" colspan="3" class="font-norm-grey"> <div align="center"></div></td> </tr> <tr> <td class="font-norm-grey"><div align="right">Credit Card:</div></td> <td width="10"> </td> <td><select name="CardType" size="1" id="CardType"> <option>Visa</option> <option>MasterCard</option> </select></td> </tr> <tr> <td class="font-norm-grey"><div align="right">Card Number:</div></td> <td width="10"> </td> <td><input name="CardNumber" type="text" id="CardNumber" size="40"></td> </tr> <tr> <td class="font-norm-grey"><div align="right">Expiration Month:</div></td> <td width="10"> </td> <td><input name="CardExpMonth" type="text" id="CardExpMonth" size="5"></td> </tr> <tr> <td class="font-norm-grey"><div align="right">Expiration Year:</div></td> <td width="10"> </td> <td><input name="CardExpYear" type="text" id="CardExpYear" size="5"></td> </tr> <tr> <td class="font-norm-grey"><div align="right">Card Validation Number:</div></td> <td width="10"> </td> <td><input name="CardAuthNumber" type="text" id="CardAuthNumber" size="5"> <span class="font-small-grey">(last 3-digit number on signature strip on back of card) </span></td> </tr> <tr> <td height="15" colspan="3" class="font-norm-grey"><div align="center"></div></td> </tr> <tr> <td class="font-norm-grey"><div align="right">Select Class:</div></td> <td width="10"> </td> <td><select name="class" id="select6"> <option>Level 1 Thu Jan 29 (8:30pm)</option> <option>Level 1 Sat Jan 31 (1:30pm)</option> <option>Level 2 Wed Jan 28 (6:30pm)</option> <option>Private Lesson (to be arranged)</option> <option>Semi-Private Group 2-3 participants (to be arranged)</option> <option>Semi-Private Group 4-6 participants (to be arranged)</option> </select></td> </tr> <tr> <td class="font-norm-grey"><div align="right">Comments:</div></td> <td width="10"> </td> <td><input name="comments" type="text" id="Address2" size="50"></td> </tr> <tr> <td class="font-norm-grey"><div align="right">How did you hear about us:</div></td> <td width="10"> </td> <td><select name="how" id="select7"> <option>Web Search</option> <option>Sexapolooza</option> <option>Business Card</option> <option>Facebook</option> <option>Friend</option> <option>Email</option> <option>Other</option> </select></td> </tr> </table> <p align="center"><span class="font-small-grey-centered"> </span> <input type="submit" name="submit" value="Submit"> </p> </form>'); } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <TITLE>Ottawa Pole Fitness - Online Registration</TITLE> <meta name="description" content="Ottawa Pole Fitness Online Registration to learn Pole Fitness Lessons"> <meta name="keywords" content="ottawa, pole, fitness, women, private, lessons, tricks, fun, workshops, 1 on 1, excersize, dance, sexy, studio, westboro, woodroofe, carlingwood, workout"> <meta name="Classification" content="fitness, pole, westboro, ottawa, ontario, canada"> <meta name="copyright" content="2008 | Li Hewitt - All Rights Reserved"> <meta name="revisit-after" content="30 days"> <meta name="Author" content="Li Hewitt"> <meta name="Location" content="CA, ON, Ottawa"> <meta name="Language" content="en-us"> <meta name="robots" content="all"> <meta name="rating" content="General"> <meta http-equiv="reply-to" content="[email protected]"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link href="css/OPF-style.css" rel="stylesheet" type="text/css"> </head> <body background="images/bg.gif"> <div align="center"><img src="images/Ottawa%20Pole%20Fitness%20Banner.gif" alt="Ottawa Pole Fitness" width="632" height="180" border="0"></div> <table width="630" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#990066"> <tr valign="bottom" bordercolor="#FFFFFF"> <td width="130" height="23" bgcolor="#FFFFFF"> <div align="center"><a href="index.htm" target="_self" class="font-menu-active">Home</a></div></td> <td width="112" height="23" bgcolor="#FFFFFF"> <div align="center"><a href="about.htm" target="_self" class="font-menu-active">About</a></div></td> <td width="105" height="23" bgcolor="#FFFFFF"> <div align="center"><a href="classes.htm" target="_self" class="font-menu-active">Classes</a></div></td> <td width="130" height="23" bgcolor="#FFFFFF"> <div align="center"><a href="schedule.htm" target="_self" class="font-menu-active">Schedule</a></div></td> <td width="153" height="23" bgcolor="#FFFFFF"> <div align="center"><a href="contact.htm" target="_self" class="font-menu-active">Contact</a></div></td> </tr> <tr valign="bottom" bordercolor="#FFFFFF"> <td height="10" colspan="5" bgcolor="#FFFFFF"><div align="center"><img src="images/line.gif" width="628" height="2"></div></td> </tr> <tr bordercolor="#FFFFFF"> <td height="20" bgcolor="#FFFFFF"> <div align="center"><a href="faq.htm" target="_self" class="font-menu-active"> FAQ</a></div></td> <td height="20" bgcolor="#FFFFFF"> <div align="center"><a href="gallery.htm" target="_self" class="font-menu-active"> Gallery</a></div></td> <td height="20" bgcolor="#FFFFFF"> <div align="center"><a href="parties.htm" target="_self" class="font-menu-active"> Parties</a></div></td> <td height="20" bgcolor="#FFFFFF"> <div align="center"><a href="prices.htm" target="_self" class="font-menu-active"> Prices</a></div></td> <td height="20" bgcolor="#FFFFFF"> <div align="center" class="font-menu-static"> Registration</div></td> </tr> <tr valign="middle" bordercolor="#FFFFFF" bgcolor="#FFFFFF"> <td height="10" colspan="5"> <p align="center"><img src="images/line.gif" width="628" height="2" align="absmiddle"></p></td> </tr> <tr valign="top" bordercolor="#FFFFFF" bgcolor="#FFFFFF"> <td height="420" colspan="5"> <blockquote> <p><br> <span class="font-norm-grey">A $30.00 deposit will be required via credit card to book your class.</span> <?php echo form($error); ?> <p class="font-small-grey-centered">Your privacy is important to us at Ottawa Pole Fitness. The information we collect is for our own purposes only and will not be given to anyone else. We use this information to keep a personal confidential file for everyone who registers with Ottawa Pole Fitness. We hate spam just as much as you do; this is why we will not distribute your information to anyone. If you have any concerns regarding our policy please contact us. <p class="font-small-grey-centered"><br> <span id="siteseal"><script type="text/javascript" src="https://seal.godaddy.com/getSeal?sealID=1514858694075d9bdcd1011f6e17e5df47fc2942603771910"></script><br/><a style="font-family:arial;font-size:9px" href="https://www.godaddy.com/gdshop/ssl/ssl.asp" target="_blank">Secure Website</a></span> </blockquote></td> </tr> </table> <div align="center"><img src="images/Ottawa%20Pole%20Fitness%20Footer.gif" width="632" height="36"> </div> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/145575-problem-with-php-script/ Share on other sites More sharing options...
rameshfaj Posted February 17, 2009 Share Posted February 17, 2009 Before some one goes to have a live test in the given URL it is better to explain what problem are u having i.e. what are the few areas in which it is not working. Quote Link to comment https://forums.phpfreaks.com/topic/145575-problem-with-php-script/#findComment-764283 Share on other sites More sharing options...
fatmikey Posted February 17, 2009 Author Share Posted February 17, 2009 Ok, this script is supposed to collect information via a form then send out 2 emails with the formatted data, but it doesn't do this. Also, it is supposed to do some basic error checking of the data entered into the form and it doesn't seem to do that either. Lastly, it is supposed to write this data to a flat file and it doesn't do that either. I am fairly new to PHP and I got some excellent help here yesterday from one of your gurus who took my script and re-wrote it to be more efficient combining php and html together. He was able to help me get the form working and sending the info off to the credit card company fine but the above things don't work now. Please Help. Thanks, Mikey Quote Link to comment https://forums.phpfreaks.com/topic/145575-problem-with-php-script/#findComment-764291 Share on other sites More sharing options...
fatmikey Posted February 17, 2009 Author Share Posted February 17, 2009 Any help would be greatly appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/145575-problem-with-php-script/#findComment-764357 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.