iEntry 10th Anniversary Forum Rules Search
WebProWorld
Register FAQ Calendar Mark Forums Read
Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome.

Share Thread: & Tags

Share Thread:

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-25-2008, 07:55 AM
WebProWorld New Member
 
Join Date: Nov 2008
Posts: 1
terrymckinven RepRank 0
Question sending form data

Hi there,

I am trying to find out how to send form data from my website back to me (using a 'submit' button) either via email or to a database and where I put this coding in relation to the actual form coding.

Here is my form coding:

<link href="mainform.css" type="text/css" rel="stylesheet" />
<div id="form">
<h2 align="left">Feedback Form</h2>
<p><span style="FONT-SIZE: 14pt">Please fill out the form below to pass on your query. If you have any urgent questions, don't hesitate to </span><a href="index.php?p=1_46"><span style="FONT-SIZE: 14pt">contact us</span></a> <span style="FONT-SIZE: 14pt">.</span></p>
<form action="feedback.php" method="post">
<p class="legend"><strong><span style="FONT-SIZE: 14pt">Personal information</span></strong></p>
<fieldset id="personal">
<label>Name:</label>
<input style="BACKGROUND-COLOR: rgb(255,255,160)" size="30" name="name" /><br />

<label>Address:</label>
<input style="BACKGROUND-COLOR: rgb(255,255,160)" size="30" name="address" /><br />

<label>Town/City:</label>
<input style="BACKGROUND-COLOR: rgb(255,255,160)" size="30" name="city" /><br />

<label>State:</label>
<input style="BACKGROUND-COLOR: rgb(255,255,160)" maxlength="3" size="3" name="state" /><br />

<label>Postcode:</label>
<input style="BACKGROUND-COLOR: rgb(255,255,160)" maxlength="5" size="5" name="postcode" /><br />

<label>Phone:</label>
<input style="BACKGROUND-COLOR: rgb(255,255,160)" maxlength="10" size="10" name="phone" /><br />

<label>Email:</label>
<input style="BACKGROUND-COLOR: rgb(255,255,160)" size="40" name="email" /><br />
</fieldset>
<p class="legend"><strong><span style="FONT-SIZE: 14pt">Choices</span></strong></p>
<fieldset id="choices">
<p id="querytype">
<label>Type of Query:</label>
<select name="querytype">
<option value="Compliment">Compliment</option>
<option value="Suggestion">Suggestion</option>
<option value="Complaint">Complaint</option>
<option value="Question">Question</option>
</select></p>
<p id="size">
<label>Size:</label>
<input type="radio" value="'F" name="size" ?? />Freestyle Aerobics
<input type="radio" value="W" name="size" />Wedding Dance
<input type="radio" value="'D" name="size" ?? />Dance
<input type="radio" value="M" name="size" />Music Editing
<input type="radio" value="T" name="size" />Translation </p>
<p id="extras">
<label>Extras:</label>
<input type="checkbox" value="salsa" name="extras[]" />Salsa
<input type="checkbox" checked="checked" value="zouk" name="extras[]" />Zouk
<input type="checkbox" value="hiphop" name="extras[]" />Hip Hop
<input type="checkbox" value="instructorworkshops" name="extras[]" />Instructor Workshops <br />
</p></fieldset>
<p class="legend"><strong><span style="FONT-SIZE: 14pt">Suggestions</span></strong></p>
<fieldset id="suggestions">
<style type="text/css">
<!--
textarea.html-text-box {background-color:ffffff;background-repeat:no-repeat;background-attachment:fixed;border-width:1;border-style:solid;border-color:cccccc;font-family:Arial;font-size:8pt;color:0000FF;}
input.html-text-box {background-color:ffffff;font-family:Arial;font-size:8pt;color:000000;}
-->
</style>
<textarea class="html-text-box" name="comments" rows="10" cols="100">Enter your comments here...></textarea><br />
</fieldset>
<p id="buttons">
<input type="submit" value="Submit" />
<input type="reset" value="Start Over" /></p>
<fieldset></fieldset>
</form></div>


I have saved 'feedback.php' to my remote root folder.

ANyway, hopefully someone can help. If you can, please be as precise as possible, as I am not a wiz at this stuff.

Thanks heaps in advance!!

Terry
Reply With Quote
  #2 (permalink)  
Old 11-25-2008, 08:06 AM
DaveSawers's Avatar
WebProWorld Veteran
 
Join Date: Dec 2006
Location: Calgary, Alberta, Canada
Posts: 438
DaveSawers RepRank 1
Default Re: sending form data

You put the action coding inside feedback.php. First you get the form parameters using for example:

$name = $_POST["name"];
etc...

Where the name inside the $_POST is the name you gave to the input tag in your form.

You can then program as necessary to either e-mail it to yourself (using the PHP mail function for example) or save it on a database.

Not sure how much you know about PHP but the place to start learning is: PHP Tutorial

and if you are already familiar with some programming in PHP, full details of the language can be found at: PHP: PHP Manual - Manual
__________________
Dynamic Software Development
www.activeminds.ca
Reply With Quote
  #3 (permalink)  
Old 11-25-2008, 03:30 PM
WebProWorld Veteran
 
Join Date: Apr 2004
Posts: 362
imvain2 RepRank 0
Default Re: sending form data

I spend time a the Kirupa site for flash stuff, but they have php articles and I found this article that does exactly what you are looking for.

kirupa.com - PHP Contact Form
Reply With Quote
  #4 (permalink)  
Old 11-25-2008, 11:00 PM
WebProWorld Veteran
 
Join Date: Oct 2003
Location: Alberta, Canada
Posts: 519
weegillis RepRank 3weegillis RepRank 3
Default Re: sending form data

Hi terrymckinven,

This may not directly apply to the question of getting a form handler in place, but it is worth giving heed to the controls that are handing user information over to the handler. Even if there are no technical errors, the quality of your form will have an impact on how much it is used, and on the reliability of the information that is passed along from the user. Valid, accessible, semantic markup is the key to ensuring the user and you get the most from web input.

Permit me to pick at the code above, just a little...

Hopefully the
Code:
<link href="mainform.css" type="text/css" rel="stylesheet" />
is in the HEAD section of your html document. Likewise, the
Code:
<style>.
element embedded in your form mark-up rightfully belongs in the head to be valid xhtml.

LABEL is intended to describe a corresponding form control, as in
Code:
<label for="querytype">Query Type</label>
<select name="querytype" id="querytype">
<option />
<option />
</select>
Note how the id=" %1 " fragment identifier attribute in the SELECT control corresponds with the for=" %1 " attribute in the LABEL element. It deserves noting that id= and name= have different uses, and should be treated independently, as a rule. Follow the W3C and WAI guidelines on this and you'll be okay.

When no FOR= attribute is included, the LABEL tag refers only to its own contents, so <label>Something</label> ends up being a label for nothing, and has no explicit ties to adjacent controls. If one wishes to use the tag in this manner, then wrap the control, as in,
Code:
<label>Options: <select><option /><option /></select></label>
or
Code:
<label><select><option /><option /></select> Options</label>
Other controls apply, including INPUT, TEXTAREA and discrete selection radio button groups and check box groups.

Empty FIELDSET elements, like most empty elements may cause validation errors, or at least TIDY errors. The old "no empty divs' rule more or less applies across the board. An exception to this would be if the element had an id= attribute intended to let Javascript identify it while generating scripted content, as in
Code:
<div id="menu"></div>
To be valid, FIELDSET needs be accompanied by a LEGEND. The normal behavior of a fieldset is to draw a border around all the controls within it, and legend provides the text title that displays at the top, within the border. These behaviors can be suppressed with CSS, but the elements should be included, even when suppressed. Assistive devices depend upon the added information and organization.

The jury may be out on the RESET button, but from an accessibility standpoint, it can lead to confusion or frustration on the part of the user. It becomes more frustrating the longer the form if one accidentally clicks the wrong button. The probability a frustrated user will refill a long form is practically nil. Something to consider. If the user really wants to start over all they need do is re-enter the page.

Where multiple selections are available, you may wish to include MAKE SELECTION, NONE SELECTED or DOES NOT APPLY as an option, then preselect it. If the user sends the form without making a choice, it won't be misleading to the person reading the information.

++++++++++++++++++

Can we assume that FEEDBACK.PHP is your form handler? If so you may wish to insulate it from the main root of your site and stash it in a restricted folder protected from prying eyes with .htacess and robots.txt. It may do well to disguise the name a little too, but this is something you will need to research.

Be sure the form handler (action="FORM_HANDLER") is configured to send output to a valid recipient, preferably on the same domain as the web form (for added credibility and 'trustworthy' replies). It follows that one might expect a reply from info+xyz.com if that's the domain from which they submitted the form. A reply from joe4567+hotmail.com will just look like spam.


It's noble that you're getting right to it, designing a powerful form, though I would recommend starting with a simple feedback form with name, e-mail and text message. This will give you a chance to get things working without all the fine details getting the way.

Cheers!
__________________
Volunteer for something in your community today!
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Send form data with PHP kurt.santo Web Programming Discussion Forum 13 01-13-2008 03:54 PM
Passing form data to remote form on another site webace Graphics & Design Discussion Forum 8 08-31-2007 03:21 AM
Form data to PDF Tim Web Programming Discussion Forum 15 04-28-2007 01:51 AM
Posting form data from a script newmarket Web Programming Discussion Forum 3 07-19-2005 02:49 AM
Pre-populating an HTML Form with Data from Another HTML Form ambassador Web Programming Discussion Forum 3 06-19-2005 09:12 PM


All times are GMT -4. The time now is 08:34 AM.



Search Engine Optimization by vBSEO 3.3.0