html forms

Discussion in 'HTML & Website Design' started by terminator69, Feb 29, 2008.

  1. #1
    I've been studying html.. I'm currently looking at different kinds of forms. Where does the data of the results go?

    eg. If you add a radio button for example asking whether someone is male or female, where does the data go and how do you use it if you add it to a webpage?

    http://www.w3schools.com/html/html_forms.asp
     
    terminator69, Feb 29, 2008 IP
  2. Wuiqed

    Wuiqed Well-Known Member

    Messages:
    110
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    108
    #2
    The data is posted to the destination defined in the action attribute. You'll then use a server-side scripting language to retrieve the posted data in the destination page. You will need a server with php to try the following example:

    form.htm
    <form action="script.php" method="post">
    	<input type="radio" name="sex" id="male" value="male" />
    	<label for="male">Male</label>
    	<input type="radio" name="sex" id="female" value="female" />
    	<label for="female">Female</label>
    	<input type="submit" name="submit_sex" value="Send!" />
    </form>
    Code (markup):

    script.php
    <?php
    	echo "You are " . $_POST['sex'];
    ?>
    PHP:
     
    Wuiqed, Mar 1, 2008 IP
    terminator69 and Bagi Zoltán like this.
  3. terminator69

    terminator69 Notable Member

    Messages:
    4,872
    Likes Received:
    260
    Best Answers:
    0
    Trophy Points:
    230
    #3
    Thanks that works. but there's no way I'm going to learn that php though. It's strange w3schools teaches how to use forms, but they're quite useless without the php to use the data??
     
    terminator69, Mar 1, 2008 IP
  4. netx

    netx Peon

    Messages:
    165
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Yes, HTML is useless without php. HTML froms can use mail.pl or mail.cgi to send the data that is filled straight into your email box.

    If is anything I can help you, add me on YM: netxme
     
    netx, Mar 1, 2008 IP
  5. Stomme poes

    Stomme poes Peon

    Messages:
    3,195
    Likes Received:
    136
    Best Answers:
    0
    Trophy Points:
    0
    #5
    There are surely scripts floating around out there that people can use. I'm sure you're not the only one who needs a form to work without learning a programming language.
     
    Stomme poes, Mar 1, 2008 IP
  6. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    437
    Best Answers:
    0
    Trophy Points:
    0
    #6
    I must point out however, that the way this form has been coded will render it inaccessible to people who rely on the keyboard for navigation as well as those who require the use of an assistive device. In the case of checkboxes and radio inputs, the input must be wrapped inside the label, with the input coming first, followed by the label text.

    Here's an example of a properly coded form (note that it doens't do anything since it's not tied to a back-end script).

    http://www.dan-schulz.com/temp/css-form-example/
     
    Dan Schulz, Mar 1, 2008 IP
  7. Stomme poes

    Stomme poes Peon

    Messages:
    3,195
    Likes Received:
    136
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Dan, the inputs Can't be wrapped in the label for Window Eyes (and then so, who else?). It ignores either the label or the input, I forget who. Also, form writers need to be able to determine which comes first, the label or the input. If they both have an id, they should still be accessible and on most browsers the label is still clickable too isn't it?

    Ah, found it.
    http://green-beast.com/blog/?p=254
     
    Stomme poes, Mar 1, 2008 IP
  8. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    437
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Damn. Forgot that affected checkboxes/radio inputs too. Oh well. Simon told me that he's fired off an email to the developers of Windows Eyes (and filed some bug reports) so this should be fixed fairly soon (I hope).
     
    Dan Schulz, Mar 1, 2008 IP
  9. Stomme poes

    Stomme poes Peon

    Messages:
    3,195
    Likes Received:
    136
    Best Answers:
    0
    Trophy Points:
    0
    #9
    But... is it only Window Eyes? Are there other, maybe less common screen readers with the same issue??
     
    Stomme poes, Mar 1, 2008 IP
  10. finite

    finite Well-Known Member

    Messages:
    133
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    103
    #10
    A recommendation, I would say use wufoo forms. There free for 3 forms and they look great. You can get the results to your email or phone.
     
    finite, Mar 1, 2008 IP
  11. risoknop

    risoknop Peon

    Messages:
    914
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    0
    #11
    You will need server-side language to retrieve data from form and do something with them. I suggest you learn PHP.

    It's free, fast, reliable and easy to learn (syntax almost same as c/c++ so if you already know little bit of those, you can start coding PHP right now).

    If you don't have experiences with PHP (or c/c++)... don't worry... scripts for handling form data are very easy - moreover you can find tons of free scripts all over the internet.
     
    risoknop, Mar 1, 2008 IP