PDA

View Full Version : Feedback Form & Templates



david_de
26-Oct-2006, 03:51 PM
Nothing fancy here but they work well together and might be helpfull. I will just post the main parts of the forms and templates.

I use the same formmail.php and fmbadhandler.php for all my forms. Each form has three templates. Good, bad, and mail templates. I use the formamil.ini file for the recipient.

The form feedback.htm

<h4>Web site Feedback Form</h4>
<form action="formmail.php" method="post" id="FeedbackForm">
<p> <input name="env_report" value="REMOTE_HOST,REMOTE_ADDR,HTTP_USER_AGENT,AUTH_TYPE,REMOTE_USER" type="hidden" />
<input name="recipients" value="me" type="hidden" />
<input name="required" value="email:Your email address,realname:Your name" type="hidden" /> <input type="hidden" name="mail_options" value="KeepLines" />

<input type="hidden" name="subject" value="Website Feedback" />
<input type="hidden" name="conditions" value=":#
#TEST#email ~ /^[a-z0-9_.]+@[a-z0-9_]+\.([a-z0-9_.]+)*[a-z0-9_.]$/i #
Please enter a valid email address.#" />
<input type="hidden" name="bad_url" value="fmbadhandler.php" />
<input type="hidden" name="this_form" value="feedback.htm" />
<input type="hidden" name="good_template" value="feedback.tpl" />
<input type="hidden" name="bad_template" value="feedback_err.tpl" />
<input type="hidden" name="mail_options" value="HTMLTemplate=feedback_mail.tpl,TemplateMissing=N/A" />
<input type="hidden" name="derive_fields" value=" date=%date%,time=%hour12%.%':'%.%min% + %AMPM%,day=%dayname%,timezone=%tzname%" />

</p>
<table border="1" cellspacing="5%" id="table1">
<tr>
<td><p>Please enter your name:</p></td>
<td>*
<input type="text" name="realname" maxlength="30" />
</td>
</tr>
<tr>
<td><p>Please enter your email address:</p></td>
<td>*
<input type="text" name="email" maxlength="60" />
</td>
</tr>
<tr>
<td>Phone number:</td>
<td><input maxlength="3" size="3" name="areacodeHXYSIP" id="areacodeHXYSIP" onblur="if(!validNumber(this.value)){if(isMSIE4Min()){this.focus();this.select();}alert('Must be numeric');}" onchange="t_HXYSIP.value=areacodeHXYSIP.value+prefixHXYSIP.value+sufixHXYSIP.value;DoRule_t_HXYSIP();" type="text" />
<strong>-</strong>
<input maxlength="3" size="3" name="prefixHXYSIP" id="prefixHXYSIP" onblur="if(!validNumber(this.value)){if(isMSIE4Min()){this.focus();this.select();}alert('Must be numeric');}" onchange="t_HXYSIP.value=areacodeHXYSIP.value+prefixHXYSIP.value+sufixHXYSIP.value;DoRule_t_HXYSIP();" type="text" />
<strong>-</strong>
<input maxlength="4" size="4" name="sufixHXYSIP" id="sufixHXYSIP" onblur="if(!validNumber(this.value)){if(isMSIE4Min()){this.focus();this.select();}alert('Must be numeric');}" onchange="t_HXYSIP.value=areacodeHXYSIP.value+prefixHXYSIP.value+sufixHXYSIP.value;DoRule_t_HXYSIP();" type="text" />
<input value="" id="t_HXYSIP" name="t_HXYSIP" onkeypress=" return noenter(this,event) " onkeydown=" return noenter(this,event) " onchange="" type="hidden" /></td>
</tr>
<tr>
<td>May we contact you?</td>
<td>Yes
<input name="contact" value="Yes Contact Me" type="radio" />
No
<input name="contact" value="No Do Not Contact Me" type="radio" />
</td>
</tr>
<tr>
<td>Subject of feedback?</td>
<td>Comment
<input name="reason" value="Comment" type="checkbox" />
Suggestion
<input name="reason" value="Suggestion" type="checkbox" />
Other
<input name="reason" value="Other" type="checkbox" />
</td>
</tr>
<tr>
<td valign="top">Please enter your message:</td>
<td><p style="text-align: center">
<textarea name="mesg" rows="5" cols="40"></textarea>
</p></td>
</tr>
<tr>
<td><input type="submit" value="Submit" /></td>
</tr>
</table>
</form> The Bad Template feedback_err.tpl

<h2>Form Error</h2>
<p><i>Please correct the errors to submit.</i> You can use your back arrow to return to the form. The previous information submited should be there. Just fill in the missing items and submit again. </p>
<p><b>Here is the full error message:</b><fmfullerror /></p>
The Good Template feedback.tpl

<h2>Success!
</h2>
<p>Thanks for submitting your information to us.</p>
<p>Here is the information you submitted:</p>
<table border="1">
<tr>
<td class="labelcell"><p style="text-align: left">Your name:</p></td>
<td class="fieldcell"><p style="text-align: left">$realname</p></td>
</tr>
<tr>
<td class="labelcell"><p style="text-align: left">Your email address:</p></td>
<td class="fieldcell"><p style="text-align: left">$email</p></td>
</tr>
<tr>
<td class="labelcell"><p style="text-align: left">Your phone number:</p></td>
<td class="fieldcell"><p style="text-align: left">$areacodeHXYSIP-$prefixHXYSIP-$sufixHXYSIP<br />
<br />
</p></td>
</tr>
<tr>
<td class="labelcell"><p style="text-align: left">May we contact you?</p></td>
<td class="fieldcell"><p style="text-align: left">$contact</p></td>
</tr>
<tr>
<td class="labelcell"><p style="text-align: left">Type of feedback:</p></td>
<td class="fieldcell"><p style="text-align: left">$reason</p></td>
</tr>
<tr>
<td class="labelcell"><p style="text-align: left">Submitted on</p></td>
<td class="fieldcell"><p style="text-align: left">$day, $date, $time, $timezone</p></td>
</tr>
<tr>
<td valign="top" class="labelcell"><p style="text-align: left">Your message to us was:</p></td>
<td class="fieldcell"><p style="text-align: left">$mesg</p></td>
</tr>
<tr><td>For your receipt<td><A HREF="javascript:window.print()">Click to Print This Page</A></td></tr>
</table> The Email Template feedback_mail.tpl

<h2>Feedback
</h2>

<p>Here is the information submitted:</p>
<table border="1">
<tr>
<td class="labelcell"><p style="text-align: left">Submitted:</p></td>
<td class="fieldcell"><p style="text-align: left">$day, $date, $time, $timezone</p></td>
</tr>
<tr>
<td class="labelcell"><p style="text-align: left">Name:</p></td>
<td class="fieldcell"><p style="text-align: left">$realname</p></td>
</tr>
<tr>
<td class="labelcell"><p style="text-align: left">Email:</p></td>
<td class="fieldcell"><p style="text-align: left">$email</p></td>
</tr>
<tr>
<td class="labelcell"><p style="text-align: left">Phone:</p></td>
<td class="fieldcell"><p style="text-align: left">$areacodeHXYSIP-$prefixHXYSIP-$sufixHXYSIP<br />
<br />
</p></td>
</tr>
<tr>
<td class="labelcell"><p style="text-align: left">Contact:</p></td>
<td class="fieldcell"><p style="text-align: left">$contact</p></td>
</tr>
<tr>
<td class="labelcell"><p style="text-align: left">Feedback:</p></td>
<td class="fieldcell"><p style="text-align: left">$reason</p></td>
</tr>
<tr>
<td valign="top" class="labelcell"><p style="text-align: left">Message:</p></td>
<td class="fieldcell"><p style="text-align: left">$mesg</p></td>
</tr>
</table>
Formmail INI formmail.ini

[email_addresses]
me = "mailsendsto@here.com"

kdeguero
09-Feb-2007, 10:47 PM
When I try this, I can get the good template to work, but no results in email, so then if I take off the good template, I get email results.
not sure what I am doing wrong, but I know I don't have the formhandler.php, so I am going to check on that now
great help btw

Mareid
25-May-2007, 12:16 AM
Thanks for the code for verifying email addresses. I happen to have an hyphen in my email address, so I quickly became aware that the hyphen is missing from the validation. So if someone wants to 'borrow' the validation code, it might be a good idea to add the hyphen to the validation