MSwanson Posted January 11, 2007 Share Posted January 11, 2007 I'm having problems getting my contact us page to work correctly, and keep chasing errors around in the script, probably because I don't really know what I'm doing. Does anyone have any suggestions?[code]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/_template.dwt" codeOutsideHTMLIsLocked="false" --><head><!-- InstanceBeginEditable name="doctitle" --><title>Contact Fox Valley Cheesecake</title><meta name="Description" content="Contact Fox Valley Cheesecake." /><meta name="Keywords" content="cheesecake, cheese cake, homemade cheesecake, unique wedding cakes, original cakes, fresh cheese cakes" /><!-- InstanceEndEditable --><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable --><link href="css/_stylesheet.css" rel="stylesheet" type="text/css" /><link href="css/_print_stylesheet.css" rel="stylesheet" type="text/css" media="print" /><SCRIPT language=javascript src="/cgi-bin/editor.cgi?prompt"></SCRIPT><script src="javascript/restore-image.js" language="JavaScript" type="text/JavaScript"></script></head><body> <div id="main_content"> <table id="layout" cellspacing="0"> <tr> <td id="page_menu"><img alt="Fox Valley Cheesecake" src="images/spacer.gif" /><p> </p></td> <td id="content"> <div editblock="head"><!-- InstanceBeginEditable name="content" --><?php if ($_SERVER['REQUEST_METHOD'] != 'POST'){ $me = $_SERVER['PHP_SELF'];?> <h2>Contact Us</h2> <p>Email: <a href="mailto:info@foxvalleycheesecake.com" target="_blank">info@foxvalleycheesecake.com</a></p> <p><strong>Fox Valley Cheesecake </strong><br /> 136 East Main Street<br /> Omro, WI 54963</p> <p> </p> <p><a href="http://www.mapquest.com/maps/map.adp?country=US&countryid=250&addtohistory=&address=136+East+Main+Street&city=Omro&state=WI&zipcode=54963&submit=Get+Map" target="_blank">Map to our location</a> </p> <p> </p> <p>Phone:<br /> <strong>(920) 685-5806</strong></p> <p> </p> <p>Fax:<br /><strong> (920) 685-5807</strong><br /> </p> <form name="form1" method="post" action="<?=$me?>"><table id="contact-us" cellspacing="0"> <tr> <td class="name"><strong>*Email:</strong></td> <td class="field"><input name="email" type="text" id="email" size="40" /></td> </tr> <tr> <td class="name"><strong>*First Name:</strong></td> <td class="field"><input name="first_name" type="text" id="first_name" size="40" /></td> </tr> <tr> <td class="name">Last Name :</td> <td class="field"><input name="last_name" type="text" id="last_name" size="40" /></td> </tr> <tr> <td class="name">Address:</td> <td class="field"><input name="address" type="text" id="address" size="40" /></td> </tr> <tr> <td class="name">City:</td> <td class="field"><input name="city" type="text" id="city" size="40" /></td> </tr> <tr> <td class="name">State/Province:</td> <td class="field"><input name="state" type="text" id="state" size="40" /></td> </tr> <tr> <td class="name">Postal/Zip Code: </td> <td class="field"><input name="zip" type="text" id="zip" size="40" /></td> </tr> <tr> <td class="name">Comments:</td> <td class="field"><textarea name="comments" cols="40" rows="4" id="comments"></textarea></td> </tr> <tr> <td class="send" colspan="2"><input type="submit" name="Submit" value="Send" /></td> </tr></table> </form> <p><strong>*Required Fields</strong></p><?php } else { error_reporting(0); // initialize a array to hold any errors we encounter $errors = array(); // test to see if the form was actually posted from our form // $page = $_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']; // if (!ereg($page, $_SERVER['HTTP_REFERER'])) // $errors[] = "Invalid referer<br>\n"; // ------------------------------------------------------------------------------------------------ // Initialize Variables - E D I T T H I S S E C T I O N $name=$HTTP_POST_VARS['first_name']; $email=$HTTP_POST_VARS['email']; $toaddress='info@foxvalleycheesecake.com'; // EMAIL TO INFO $fromaddress='info@foxvalleycheesecake.com'; $replyaddress=$HTTP_POST_VARS['email']; $subject='Contact from '$HTTP_POST_VARS['first_name']' '$HTTP_POST_VARS['last_name']; $content = ' <html> <body><table id="contact-us" cellspacing="0"> <tr> <td class="name">Email:</td> <td class="name">'$HTTP_POST_VARS['email']'</td> </tr> <tr> <td class="name">First Name:</td> <td class="name">'$HTTP_POST_VARS['first_name']'</td> </tr> <tr> <td class="name">Last Name :</td> <td class="name">'$HTTP_POST_VARS['last_name']'</td> </tr> <tr> <td class="name">Address:</td> <td class="name">'$HTTP_POST_VARS['address']'</td> </tr> <tr> <td class="name">City:</td> <td class="name">'$HTTP_POST_VARS['city']'</td> </tr> <tr> <td class="name">State/Province:</td> <td class="name">'$HTTP_POST_VARS['state']'</td> </tr> <tr> <td class="name">Postal/Zip Code: </td> <td class="name">'$HTTP_POST_VARS['zip']'</td> </tr> <tr> <td class="name">Comments:</td> <td class="name">'wordwrap( $HTTP_POST_VARS['comments'])'</td> </tr></table> $autotoaddress=$HTTP_POST_VARS['email']; // AUTORESPONDER EMAIL INFO $autofromaddress='info@foxvalleycheesecake.com'; $autosubject='Thank you for your inquiry'; $autocontent='Thank you for submitting your inquiry to foxvalleycheesecake.com. We value your business and will reply as soon as possible.'; $thanksmessage='<h1 align="center"><br>Thanks for your submission.<br /><br>We will respond as soon as possible.</h1><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>'; //Thank You Screen $linkhome='<div align="center"></div>'; // ------------------------------------------------------------------------------------------------- // check to see if a name was entered if (!$_POST['first_name']) { $errors[] = "<br /><span>Please enter your first name.</span><br />"; } // Check for valid email address - validation regular expression $regexp = "^[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.([a-zA-Z]{2,4})$"; if (!eregi($regexp, $email)) { $errors[] = "<br /><span>Please enter a valid email address.</span><br />\n"; } // if there are any errors, display them if (count($errors)>0) { foreach($errors as $err) echo "$err<br>\n"; echo "<br>Please use your browser's Back button to correct your entry."; } else { // no errors, so send email message mail($toaddress, $subject, $content, "From: $fromaddress", "Reply-To: $replyaddress"); // no errors, so send autoresponder mail($autotoaddress, $autosubject, $autocontent, "From: $autofromaddress"); // Completed Message echo $thanksmessage; echo $linkhome; } }?> <!-- InstanceEndEditable --></div><!-- editblock="head" --> </td> </tr> <tr> <td id="footer" colspan="2"></td> </tr></table> </div> <!-- left side menu divs --><div class="menu" id="home"><a href="index.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('rohome','','images/bt-dk-home.jpg',1)"><img alt="Home" name="rohome" id="rohome" src="images/bt-lt-home.jpg" width="145" height="26" border="0" /></a></div><div class="menu" id="about"><a href="about-us.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('roabout','','images/bt-dk-about.jpg',1)"><img alt="About Fox Valley Cheesecake" name="roabout" id="roabout" src="images/bt-lt-about.jpg" border="0" /></a></div><div class="menu" id="browse"><a href="store/cart.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('robrowse','','images/bt-dk-browse.jpg',1)"><img alt="Browse Products" name="robrowse" id="robrowse" src="images/bt-lt-browse.jpg" border="0" /></a></div><div class="menu" id="featured"><a href="store/cart.php?m=product_list&c=8" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('rofeatured','','images/bt-dk-featured.jpg',1)"><img alt="Featured Products" name="rofeatured" id="rofeatured" src="images/bt-lt-featured.jpg" border="0" /></a></div><div class="menu" id="new"><a href="store/cart.php?m=product_list&c=9" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('ronew','','images/bt-dk-new.jpg',1)"><img alt="New Products" name="ronew" id="ronew" src="images/bt-lt-new.jpg" border="0" /></a></div><div class="menu" id="gift"><a href="store/cart.php?m=product_detail&p=48" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('rogift','','images/bt-dk-gift.jpg',1)"><img alt="Gift Certificates" name="rogift" id="rogift" src="images/bt-lt-gift.jpg" border="0" /></a></div><div class="menu" id="basket"><a href="store/cart.php?m=view" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('robasket','','images/bt-dk-basket.jpg',1)"><img alt="My Basket" name="robasket" id="robasket" src="images/bt-lt-basket.jpg" border="0" /></a></div><div class="menu" id="account"><a href="store/login.php?m=client_login" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('roaccount','','images/bt-dk-account.jpg',1)"><img alt="My Account" name="roaccount" id="roaccount" src="images/bt-lt-account.jpg" border="0" /></a></div><div class="menu" id="contact"><a href="contact-us.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('rocontact','','images/bt-dk-contact.jpg',1)"><img alt="Contact Us" name="rocontact" id="rocontact" src="images/bt-lt-contact.jpg" border="0" /></a></div><div class="menu" id="fund"><a href="fundraising.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('rofund','','images/bt-dk-fund.jpg',1)"><img alt="Fund raising " name="rofund" id="rofund" src="images/bt-lt-fund.jpg" border="0" /></a></div><div class="menu" id="corporate"><a href="corporate-gifts.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('rocorporate','','images/bt-dk-corporate.jpg',1)"><img src="images/bt-lt-corporate.jpg" alt="Corportate Gifts" name="rocorporate" width="145" height="24" border="0" id="rocorporate" /></a></div><div class="menu" id="wedding"><a href="wedding-cakes.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('rowedding','','images/bt-dk-wedding.jpg',1)"><a href="wedding-cakes.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('rowedding','','images/bt-dk-wedding.jpg',1)"><img src="images/bt-lt-wedding.jpg" alt="Wedding Cakes" name="rowedding" width="145" height="26" border="0" id="rowedding" /></a></div><div id="credit-card"><img alt="Accepted Credit Cards" src="images/credit-card-logos.jpg" width="100" height="68" /></div><div id="header"></div></body><!-- InstanceEnd --></html>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/33783-contact-us-page/ Share on other sites More sharing options...
Ninjakreborn Posted January 11, 2007 Share Posted January 11, 2007 The coding is very sloppy, looks like multiple third party scripts. I would throw away anything not needed, and have someone (a friend or something), recode the form and processor, make it valid and look cleaner (it would even run faster, and fix your problems at the same time) Quote Link to comment https://forums.phpfreaks.com/topic/33783-contact-us-page/#findComment-158453 Share on other sites More sharing options...
redbullmarky Posted January 11, 2007 Share Posted January 11, 2007 dude, telling someone to get someone else to write it isnt gonna help too much ;)what i'd suggest though, MSwanson - if you're getting any specific errors, try and post just the error and the code around it - that's a hell of alot of code to look through :)cheers Quote Link to comment https://forums.phpfreaks.com/topic/33783-contact-us-page/#findComment-158456 Share on other sites More sharing options...
MSwanson Posted January 11, 2007 Author Share Posted January 11, 2007 The error I'm getting right now is:Parse error: parse error, unexpected T_VARIABLE in c:\inetpub\wwwroot\contact-us.php on line 107Which puts us here:<code> $name=$HTTP_POST_VARS['first_name']; $email=$HTTP_POST_VARS['email']; $toaddress='info@foxvalleycheesecake.com'; // EMAIL TO INFO $fromaddress='info@foxvalleycheesecake.com'; $replyaddress=$HTTP_POST_VARS['email']; $subject='Contact from '$HTTP_POST_VARS['first_name']' '$HTTP_POST_VARS['last_name'];</code>I did realize that the script is messy, but a friend kind of dumped this project in my lap (since they lost their programmer) and I'm a little over my head.On a related not, I can't seem to get the code tags to work to enclose my code when I post in the forum...I must be doin something wrong...and if I can't figure out how to post in the forum, no wonder I can't make the script work. ??? Quote Link to comment https://forums.phpfreaks.com/topic/33783-contact-us-page/#findComment-158469 Share on other sites More sharing options...
MSwanson Posted January 11, 2007 Author Share Posted January 11, 2007 As for rewritting the script I'd love to, but don't know anyone that wants/can do it and have a non-exsistant budget to make that (and a couple other changes happen)...any volunteers? ;D Quote Link to comment https://forums.phpfreaks.com/topic/33783-contact-us-page/#findComment-158472 Share on other sites More sharing options...
Daniel0 Posted January 11, 2007 Share Posted January 11, 2007 The line that does the problems is [code]$subject='Contact from '$HTTP_POST_VARS['first_name']' '$HTTP_POST_VARS['last_name'];[/code]Change it to: [code]$subject = "Contact from {$_POST['first_name']} {$_POST['last_name']}";[/code]Note the change from single quotes to double quotes and the change from $HTTP_POST_VARS to $_POST. It was due to wrong syntax.Edit: Also note that just by adding spaces between the assignment operator (the equal sign) and the string makes it look nicer (IMO). Quote Link to comment https://forums.phpfreaks.com/topic/33783-contact-us-page/#findComment-158485 Share on other sites More sharing options...
MSwanson Posted January 11, 2007 Author Share Posted January 11, 2007 I'm still getting an error:Parse error: parse error, unexpected T_VARIABLE in c:\inetpub\wwwroot\contact-us.php on line 110[code] // Initialize Variables $name = $_POST['first_name']; $email = $_POST['email']; $toaddress = 'info@foxvalleycheesecake.com'; // EMAIL TO INFO $fromaddress = 'info@foxvalleycheesecake.com'; $replyaddress = $_POST['email']; $subject = "Contact from {$_POST['first_name']} {$_POST['last_name']}"; $content = $_POST['comments'] $autotoaddress = $_POST['email']; // AUTORESPONDER EMAIL INFO $autofromaddress = 'info@foxvalleycheesecake.com'; $autosubject = 'Thank you for your inquiry'; $autocontent = 'Thank you for submitting your inquiry to foxvalleycheesecake.com. We value your business and will reply as soon as possible.'; $thanksmessage = '<h1 align="center"><br>Thanks for your submission.<br /><br>We will respond as soon as possible.</h1><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>'; //Thank You Screen $linkhome = '<div align="center"></div>';[/code] Quote Link to comment https://forums.phpfreaks.com/topic/33783-contact-us-page/#findComment-158499 Share on other sites More sharing options...
Daniel0 Posted January 11, 2007 Share Posted January 11, 2007 Change [code] $content = $_POST['comments'][/code] to [code] $content = $_POST['comments'];[/code]Edit: Another time please point out the line that the error message is talking about. Quote Link to comment https://forums.phpfreaks.com/topic/33783-contact-us-page/#findComment-158501 Share on other sites More sharing options...
MSwanson Posted January 11, 2007 Author Share Posted January 11, 2007 So, now I'm not getting an error, but the mail doesn't seem to be coming through, either. Quote Link to comment https://forums.phpfreaks.com/topic/33783-contact-us-page/#findComment-158508 Share on other sites More sharing options...
MSwanson Posted January 11, 2007 Author Share Posted January 11, 2007 I've checked my email filter settings, and gone through the archive of the messages that haven't been delivered, and the messages are going there, either. Quote Link to comment https://forums.phpfreaks.com/topic/33783-contact-us-page/#findComment-158521 Share on other sites More sharing options...
MSwanson Posted January 11, 2007 Author Share Posted January 11, 2007 I think my problem now has to do with the way my PHP is working since when I try to test the mail() function, I don't get anything either.I have tried to test it with:[code]<?php mail('matthew@foxvalleycheesecake.com', 'Test Subject', 'Test Message'); ?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/33783-contact-us-page/#findComment-158549 Share on other sites More sharing options...
Daniel0 Posted January 11, 2007 Share Posted January 11, 2007 If your mail filter gets them, then maybe you need more loose settings? Quote Link to comment https://forums.phpfreaks.com/topic/33783-contact-us-page/#findComment-158689 Share on other sites More sharing options...
MSwanson Posted January 12, 2007 Author Share Posted January 12, 2007 I've got the script working (almost) and I'm receiving the messages. Quote Link to comment https://forums.phpfreaks.com/topic/33783-contact-us-page/#findComment-158785 Share on other sites More sharing options...
MSwanson Posted January 12, 2007 Author Share Posted January 12, 2007 So now that I have the basic script working, I'm trying to send the message as an html message. I keep getting either T_STRING or T_ENCAPSED_AND_WHITESPACE errors that are happening in the "content" section. Any help would be appreciated![code] $name = $_POST['first_name']; $email = $_POST['email']; $toaddress = 'info@foxvalleycheesecake.com'; // EMAIL TO INFO $fromaddress = $_POST['email']; $replyaddress = $_POST['email']; $subject = "FVCC Contact from {$_POST['first_name']} {$_POST['last_name']}"; //$content = $_POST['comments']; $content = '<html><head> <title>Website Contact</title></head><body><strong>Customer Information: </strong><br>{$_POST['first_name']} {$_POST['last_name']}{$_POST['address']}{$_POST['city'], {$_POST['state']} {$_POST['zip']}<br><strong>Email Address:</strong>{$_POST['email']}<br><strong>Comments:</strong>{wordwrap($_POST['comments'])}</body></html>';[/code] Quote Link to comment https://forums.phpfreaks.com/topic/33783-contact-us-page/#findComment-158836 Share on other sites More sharing options...
MSwanson Posted January 12, 2007 Author Share Posted January 12, 2007 *BUMP* Quote Link to comment https://forums.phpfreaks.com/topic/33783-contact-us-page/#findComment-159129 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.