powersitedesign Posted July 11, 2008 Share Posted July 11, 2008 I have been working on a project for a client and have run into a bit of a snag, I am sure that this is some sort of syntax thing but I can't get my mind around it. I use a code generator called PHPRunner, it has a visual editor that utilizes Smarty Templates. I am trying to add a simple PHP Form to the view pages of my clients database records to utilize some records from the database like resort_name and resort_email, etc. The form is not intended to capture any data at all, just send an email out to the resort owners via their profile page, here's a link to the page as it is now so you can get a better idea: http://www.ownershipresorts.com/cms/resorts_database_view.php?editid1=145 My first issue was that I was getting Smarty Template Errors once I stuck the form into the template. I read on Smarty's forum about using the {literal} tag for javascript so I wrapped the form w/ it to make the error go away. Of course the form doesn't work either, but when I pull the form out and load it on the server it works fine so i know it's not the form, it has to be in the way I am coding the smarty template. I am copying my code here, hopefully someone can help me figure out how to make this work. Thanks for your help in advance! <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD><TITLE>Resorts Database (web)</TITLE> <META http-equiv=Content-Type content="text/html; charset=windows-1252"> <META content="MSHTML 6.00.6000.16681" name=GENERATOR></HEAD> <BODY bgColor=#000000><script type="text/javascript" src="include/ibox.js"></script><LINK media=screen href="include/ibox.css" type=text/css rel=stylesheet><script type="text/javascript" src="include/jquery.js"></script>{doevent name="ViewOnLoad"}<!--startPDFcut--> <DIV align=center> <TABLE cellPadding=2 width=645 bgColor=#f8f7e5 border=0> <TBODY> <TR> <TD bgColor=#cdcaa5><SPAN style="FONT-WEIGHT: 700"><FONT style="FONT-SIZE: 8pt" face=Verdana>Resort Details: </FONT></SPAN></TD></TR> <TR> <TD vAlign=top> <DIV align=center> <TABLE cellSpacing=4 cellPadding=4 width="100%" border=0> <TBODY> <TR> <TD vAlign=top width="50%"> <DIV align=center> <TABLE cellSpacing=3 cellPadding=3 width="100%" border=0> <TBODY> <TR> <TD style="HEIGHT: 226px" width=300 height=226><IMG id=imgMainPhoto src="{$row00firstphoto_value}"></TD></TR> <TR> <TD> <DIV align=center> <TABLE cellPadding=2 width=300 border=0> <TBODY> <TR> <TD>{$show_resort_photo_1}</TD> <TD>{$show_resort_photo_2}</TD> <TD>{$show_resort_photo_3}</TD> <TD>{$show_resort_photo_4}</TD></TR> <TR> <TD>{$show_resort_photo_5}</TD> <TD>{$show_resort_photo_6}</TD> <TD>{$show_resort_photo_7}</TD> <TD>{$show_resort_photo_8}</TD></TR></TBODY></TABLE></DIV></TD></TR> <TR> <TD></TD></TR> <TR> <TD bgColor=#ebdca4><FONT style="FONT-WEIGHT: 700; FONT-SIZE: 8pt" face=Verdana>Contact Us:</FONT></TD></TR> <TR> <TD bgColor=#cdcaa5><!-- THIS IS WHERE THE FORM CODE NEEDS TO BE DROPPED INTO THE TEMPLATE -->{literal}<?php // Change these two variables to meet your needs. $myemail = 'cotton.rohrscheib@pleth.com'; $subject = '{$show_resort_name} Inquiry'; $op = $_POST[op]; if($op == 'contact') { $name = stripslashes($_POST[name]); $address = stripslashes($_POST[address]); $city = stripslashes($_POST[city]); $state1 = stripslashes($_POST[state1]); $zip = stripslashes($_POST[zip]); $phone_1 = stripslashes($_POST[phone_1]); $phone_2 = stripslashes($_POST[phone_2]); $phone_3 = stripslashes($_POST[phone_3]); $email = stripslashes($_POST[email]); $questions_comments = stripslashes($_POST[questions_comments]); $referer = $_POST[referer]; $remote_host = $_SERVER[REMOTE_ADDR]; $server = $_SERVER[sERVER_NAME]; $browser = $_SERVER[HTTP_USER_AGENT]; if(!eregi("^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$",$email)) { $status = "<br>Please enter a valid email address.<br>"; } if(!$name) { $status .= "Please enter your name.<br>"; } if(!$questions_comments) { $status .= "Please enter a message.<br>"; } if(!$status) { $header = "From: $email\r\nReply-To: $email\r\n"; $message = " ----- Contact Information -------------------------------------------- Name: $name Company: $company Address: $address City: $city State: $state1 Zip: $zip Phone: ($phone_1)$phone_2-$phone_3 Email: $email Method: $method / $method_other ----- Questions / Comments-------------------------------------------- Questions/Comments: $questions_comments ----- Referer & Browser Data ----------------------------------------- Referer: $referer Site: $server Remote Host: $remote_host Remote Browser: $browser "; if(mail($myemail, $subject, $message, $header)) { $status = "Thanks, Your Message was Sent!<br><br>"; } else { $status = "Error: There was a problem with your message! Please email us: info@ownershipresorts.com.<br><br>"; } } else { $status .= "<br>Please press <u>back</u> on your browser to resubmit this form.<br><br>"; } } // Now check the referer page and ensure it's a proper URL $referer = $_SERVER[HTTP_REFERER]; if(!preg_match('#^http://[a-z0-9-]+.([a-z0-9-]+.)?[a-z]+#i', $referer)) { unset($referer); } ?><?php print $status; ?></SPAN> <P></P> <FORM language=JavaScript name=FrontPage_Form1 onsubmit="return FrontPage_Form1_Validator(this)" action="<?php print $_SELF; ?>" method=post><input type="hidden" name="op" value="contact"><input type="hidden" name="referer" value="<?php print $referer; ?>"> <TABLE style="WIDTH: 284px" cellSpacing=1> <TBODY> <TR> <TD align=left width=163><FONT style="FONT-SIZE: 8pt" face=Verdana>Name:*</FONT></TD> <TD align=left width=169><FONT color=#ffffff><!--webbot bot="Validation" b-value-required="TRUE" --><INPUT style="BORDER-RIGHT: #ffffff 1px solid; BORDER-TOP: #ffffff 1px solid; FONT-SIZE: 8pt; BORDER-LEFT: #ffffff 1px solid; COLOR: #000000; BORDER-BOTTOM: #ffffff 1px solid; FONT-FAMILY: Verdana; BACKGROUND-COLOR: #ffffa0" tabIndex=1 size=25 name=name></FONT></TD></TR> <TR> <TD align=left width=163><FONT style="FONT-SIZE: 8pt" face=Verdana>Address:</FONT></TD> <TD align=left width=169><FONT color=#ffffff><INPUT style="BORDER-RIGHT: #ffffff 1px solid; BORDER-TOP: #ffffff 1px solid; FONT-SIZE: 8pt; BORDER-LEFT: #ffffff 1px solid; COLOR: #000000; BORDER-BOTTOM: #ffffff 1px solid; FONT-FAMILY: Verdana; BACKGROUND-COLOR: #ffffa0" tabIndex=3 size=25 name=address></FONT></TD></TR> <TR> <TD align=left width=163><FONT style="FONT-SIZE: 8pt" face=Verdana>City:</FONT></TD> <TD align=left width=169><FONT color=#ffffff><INPUT style="BORDER-RIGHT: #ffffff 1px solid; BORDER-TOP: #ffffff 1px solid; FONT-SIZE: 8pt; BORDER-LEFT: #ffffff 1px solid; COLOR: #000000; BORDER-BOTTOM: #ffffff 1px solid; FONT-FAMILY: Verdana; BACKGROUND-COLOR: #ffffa0" tabIndex=4 size=25 name=city></FONT></TD></TR> <TR> <TD align=left width=163><FONT style="FONT-SIZE: 8pt" face=Verdana>State/Province:</FONT></TD> <TD align=left width=169><FONT color=#ffffff><select name="state1" tabindex="5" style="font-family: Verdana; font-size: 8pt; color: #000000; border: 1px solid #FFFFFF; background-color:#FFFFA0" size="1"> <option value="AL">Alabama</option> <option value="AK">Alaska</option> <option value="AZ">Arizona</option> <option value="AR">Arkansas</option> <option value="CA">California</option> <option value="CO">Colorado</option> <option value="CT">Connecticut</option> <option value="DE">Delaware</option> <option value="DC">District of Columbia</option> <option value="FL">Florida</option> <option value="GA">Georgia</option> <option value="HI">Hawaii</option> <option value="ID">Idaho</option> <option value="IL">Illinois</option> <option value="IN">Indiana</option> <option value="IA">Iowa</option> <option value="KS">Kansas</option> <option value="KY">Kentucky</option> <option value="LA">Louisiana</option> <option value="ME">Maine</option> <option value="MD">Maryland</option> <option value="MA">Massachusetts</option> <option value="MI">Michigan</option> <option value="MN">Minnesota</option> <option value="MS">Mississippi</option> <option value="MO">Missouri</option> <option value="MT">Montana</option> <option value="NE">Nebraska</option> <option value="NV">Nevada</option> <option value="NH">New Hampshire</option> <option value="NJ">New Jersey</option> <option value="NM">New Mexico</option> <option value="NY">New York</option> <option value="NC">North Carolina</option> <option value="ND">North Dakota</option> <option value="OH">Ohio</option> <option value="OK">Oklahoma</option> <option value="OR">Oregon</option> <option value="PA">Pennsylvania</option> <option value="RI">Rhode Island</option> <option value="SC">South Carolina</option> <option value="SD">South Dakota</option> <option value="TN">Tennessee</option> <option value="TX">Texas</option> <option value="UT">Utah</option> <option value="VT">Vermont</option> <option value="VA">Virginia</option> <option value="WA">Washington</option> <option value="WV">West Virginia</option> <option value="WI">Wisconsin</option> <option value="WY">Wyoming</option> <option value="--">-----</option> <option id="CAN-AB" value="AB">Alberta</option> <option id="CAN-BC" value="BC">British Columbia</option> <option id="CAN-MB" value="MB">Manitoba</option> <option id="CAN-NB" value="NB">New Brunswick</option> <option id="CAN-NL" value="NL">New & Lab</option> <option id="CAN-NT" value="NT">NW Territories</option> <option id="CAN-NS" value="NS">Nova Scotia</option> <option id="CAN-NU" value="NU">Nunavut</option> <option id="CAN-PE" value="PE">PEI</option> <option id="CAN-SK" value="SK">Saskatchewan</option> <option id="CAN-ON" value="ON">Ontario</option> <option id="CAN-QC" value="QC">Quebec</option> <option id="CAN-YT" value="YT">Yukon</option> <option value="-1">------</option> <option value="-2">Not Listed</option></select></FONT></TD></TR> <TR> <TD align=left width=163><FONT style="FONT-SIZE: 8pt" face=Verdana>Zip Code:</FONT></TD> <TD align=left width=169><FONT color=#ffffff><!--webbot bot="Validation" s-data-type="Integer" s-number-separators="x" i-maximum-length="10" --><INPUT style="BORDER-RIGHT: #ffffff 1px solid; BORDER-TOP: #ffffff 1px solid; FONT-SIZE: 8pt; BORDER-LEFT: #ffffff 1px solid; COLOR: #000000; BORDER-BOTTOM: #ffffff 1px solid; FONT-FAMILY: Verdana; BACKGROUND-COLOR: #ffffa0" tabIndex=6 maxLength=10 size=10 name=zip></FONT></TD></TR> <TR> <TD align=left width=163><FONT style="FONT-SIZE: 8pt" face=Verdana>Telephone:</FONT></TD> <TD align=left width=169><FONT style="FONT-SIZE: 8pt" face=Verdana>(</FONT><FONT color=#ffffff><!--webbot bot="Validation" s-data-type="Integer" s-number-separators="x" i-maximum-length="3" s-validation-constraint="Greater than or equal to" s-validation-value="000" s-validation-constraint="Less than or equal to" s-validation-value="999" --><INPUT style="BORDER-RIGHT: #ffffff 1px solid; BORDER-TOP: #ffffff 1px solid; FONT-SIZE: 8pt; BORDER-LEFT: #ffffff 1px solid; COLOR: #000000; BORDER-BOTTOM: #ffffff 1px solid; FONT-FAMILY: Verdana; BACKGROUND-COLOR: #ffffa0" tabIndex=7 maxLength=3 size=3 name=phone_1></FONT><FONT face=Verdana><SPAN style="FONT-SIZE: 8pt">)</SPAN></FONT><FONT color=#ffffff><!--webbot bot="Validation" s-data-type="Integer" s-number-separators="x" i-maximum-length="3" s-validation-constraint="Greater than or equal to" s-validation-value="000" s-validation-constraint="Less than or equal to" s-validation-value="999" --><INPUT style="BORDER-RIGHT: #ffffff 1px solid; BORDER-TOP: #ffffff 1px solid; FONT-SIZE: 8pt; BORDER-LEFT: #ffffff 1px solid; COLOR: #000000; BORDER-BOTTOM: #ffffff 1px solid; FONT-FAMILY: Verdana; BACKGROUND-COLOR: #ffffa0" tabIndex=7 maxLength=3 size=3 name=phone_2>-<!--webbot bot="Validation" s-data-type="Integer" s-number-separators="x" i-maximum-length="4" s-validation-constraint="Greater than or equal to" s-validation-value="0000" s-validation-constraint="Less than or equal to" s-validation-value="9999" --><INPUT style="BORDER-RIGHT: #ffffff 1px solid; BORDER-TOP: #ffffff 1px solid; FONT-SIZE: 8pt; BORDER-LEFT: #ffffff 1px solid; COLOR: #000000; BORDER-BOTTOM: #ffffff 1px solid; FONT-FAMILY: Verdana; BACKGROUND-COLOR: #ffffa0" tabIndex=7 maxLength=4 size=4 name=phone_3></FONT></TD></TR> <TR> <TD align=left width=163><FONT style="FONT-SIZE: 8pt" face=Verdana>Email Address:*</FONT></TD> <TD align=left width=169><FONT color=#ffffff><!--webbot bot="Validation" s-data-type="String" b-allow-letters="TRUE" b-allow-digits="TRUE" s-allow-other-chars="@." b-value-required="TRUE" --><INPUT style="BORDER-RIGHT: #ffffff 1px solid; BORDER-TOP: #ffffff 1px solid; FONT-SIZE: 8pt; BORDER-LEFT: #ffffff 1px solid; COLOR: #000000; BORDER-BOTTOM: #ffffff 1px solid; FONT-FAMILY: Verdana; BACKGROUND-COLOR: #ffffa0" tabIndex=10 size=25 name=email></FONT></TD></TR> <TR> <TD align=left width=163> </TD> <TD align=left width=169> </TD></TR> <TR> <TD vAlign=top align=left width=163><FONT style="FONT-SIZE: 8pt" face=Verdana>Questions / Comments:*</FONT></TD> <TD align=left width=169><FONT color=#ffffff><!--webbot bot="Validation" b-value-required="TRUE" --><TEXTAREA style="BORDER-RIGHT: #ffffff 1px solid; BORDER-TOP: #ffffff 1px solid; FONT-SIZE: 8pt; BORDER-LEFT: #ffffff 1px solid; BORDER-BOTTOM: #ffffff 1px solid; FONT-FAMILY: Verdana; BACKGROUND-COLOR: #ffffa0" tabIndex=13 name=questions_comments rows=5 cols=25></TEXTAREA></FONT></TD></TR> <TR> <TD vAlign=top width=163> </TD> <TD align=left width=169><FONT style="FONT-SIZE: 8pt" face=Verdana>* = Required Fields</FONT></TD></TR> <TR> <TD colSpan=2> </TD></TR> <TR> <TD colSpan=2> <P align=center><INPUT style="BORDER-RIGHT: #ffffff 1px solid; BORDER-TOP: #ffffff 1px solid; FONT-WEIGHT: bold; FONT-SIZE: 8pt; BORDER-LEFT: #ffffff 1px solid; COLOR: #000000; BORDER-BOTTOM: #ffffff 1px solid; FONT-FAMILY: Verdana; BACKGROUND-COLOR: #ebdca4" type=submit value=Submit></P></TD></TR></TBODY></TABLE> </FORM>{/literal}<!-- INSIDE THIS FORM I NEED TO PASS ALONG TWO RECORDS FROM THE DATABASE FOR EACH RESORT, {$show_resort_name} {$show_resort_email} --><!-- THIS IS WHERE THE FORM CODE ENDS --> <P></P> <P></P> <P></P> <P>{$show_resort_email}</P></TD></TR></TBODY></TABLE></DIV></TD> <TD vAlign=top width=340> <DIV align=center> <TABLE cellSpacing=3 cellPadding=3 width="100%" border=0> <TBODY> <TR> <TD width="100%"><FONT style="FONT-WEIGHT: 700; FONT-SIZE: 8pt" face=Verdana>{$show_resort_name}</FONT><FONT style="FONT-SIZE: 8pt" face=Verdana><BR>{$show_resort_address}<BR>{$show_resort_city}, {$show_resort_state} {$show_resort_zip}<BR>{$show_resort_telephone_1}<BR>{$show_resort_telephone_2}<BR>{$show_resort_website}</FONT></TD></TR> <TR> <TD width=192> </TD></TR> <TR> <TD width=192 bgColor=#ebdca4><SPAN style="FONT-WEIGHT: 700"><FONT style="FONT-SIZE: 8pt" face=Verdana>About Our Resort:</FONT></SPAN></TD></TR> <TR> <TD width="100%"><FONT style="FONT-SIZE: 8pt" face=Verdana>{$show_resort_notes}</FONT></TD></TR> <TR> <TD width=192> </TD></TR> <TR> <TD width=192 bgColor=#ebdca4><SPAN style="FONT-WEIGHT: 700"><FONT style="FONT-SIZE: 8pt" face=Verdana>Unique Amenities:</FONT></SPAN></TD></TR> <TR> <TD width="100%" bgColor=#cdcaa5><FONT style="FONT-SIZE: 8pt" face=Verdana>{$show_resort_unique_amenities}</FONT></TD></TR> <TR> <TD width=192> </TD></TR> <TR> <TD width=192 bgColor=#ebdca4><SPAN style="FONT-WEIGHT: 700"><FONT style="FONT-SIZE: 8pt" face=Verdana>Restrictions:</FONT></SPAN></TD></TR> <TR> <TD width="100%" bgColor=#cdcaa5><FONT style="FONT-SIZE: 8pt" face=Verdana>{$show_resort_restrictions} </FONT></TD></TR> <TR> <TD width=192> </TD></TR> <TR> <TD width=192 bgColor=#ebdca4><SPAN style="FONT-WEIGHT: 700"><FONT style="FONT-SIZE: 8pt" face=Verdana>Attractions:</FONT></SPAN></TD></TR> <TR> <TD width="100%" bgColor=#cdcaa5><FONT style="FONT-SIZE: 8pt" face=Verdana>{$show_resort_attractions}</FONT></TD></TR></TBODY></TABLE></DIV></TD></TR> <TR> <TD vAlign=top width="100%" colSpan=2> </TD></TR> <TR> <TD vAlign=top align=middle width="100%" colSpan=2> <DIV align=center> <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0> <TBODY> <TR> <TD width=265><IMG src="images/resort1.jpg" align=right border=0></TD> <TD><FONT style="FONT-WEIGHT: 700; FONT-SIZE: 8pt" face=Verdana>Content Copyrighted 2008 - Ownership Resorts</FONT></TD></TR></TBODY></TABLE></DIV></TD></TR></TBODY></TABLE></DIV></TD></TR> <TR> <TD> </TD></TR></TBODY></TABLE></DIV>{literal}<script> var _imgMainPhoto = document.getElementById("imgMainPhoto"); function LoadMainPhoto(photoUrl) { _imgMainPhoto.src = photoUrl; } </script>{/literal}<!--endPDFcut--></BODY></HTML> Quote Link to comment Share on other sites More sharing options...
chronister Posted July 12, 2008 Share Posted July 12, 2008 My only suggestion is not much help for you. don't use smarty, use actual php. The reason I say this is because of errors like this. When you have an error in PHP you can decipher it and determine where the php code went wrong. With Smarty, you have to determine where the smarty templating whent wrong. Sorry I can't give you a better answer to your question, but I HATE smarty. I tried "using" it once and determined that I did not want to learn smarty's syntax in addition to php's syntax. Hope someone else can help you more. (but seriously learn straight PHP and code things yourself, it's more rewarding and easier to debug) Nate Quote Link to comment Share on other sites More sharing options...
powersitedesign Posted July 12, 2008 Author Share Posted July 12, 2008 Thanks for your reply, that's more response than I have gotten from the Smarty Community on their forum all day long! I can appreciate what you are saying about avoiding templating engines but for me it's a huge convenience, I have a lot of clients and usually 2 or 3 projects going at one time, pretty much all of them somewhat dynamic, it's hard to stay on top of them all especially handcoding w/ eclipse or another editor, w/ PHPRunner IDE and it's Code Generation it's really cut down a lot of my development time since using it. I will be the first to admit that there are some drawbacks at times with using a template engine and doing code generation just like right now in situations like this when my code is broken! Oh well, maybe someone else on here can help me out. Quote Link to comment 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.