how to use htmlspecialchars in the form - help

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • leegold2

    how to use htmlspecialchars in the form - help

    Newbie question I guess. Please show me how to use the htmlspecialchar s
    function in the form below, Thanks:



    <form action="formtes t1.php?c=1" method=POST>
    <b>Find Results with:
    These words: <input type="text" length=40 name="keywords" >
    input type="submit" value="Search">
    </form>

  • Michael Fesser

    #2
    Re: how to use htmlspecialchar s in the form - help

    .oO(leegold2)
    [color=blue]
    >Newbie question I guess. Please show me how to use the htmlspecialchar s
    >function in the form below, Thanks:[/color]

    You only need it when you print out the previously entered informations
    again, which is not the case with your form (no default value for the
    input field).

    Usually the code would look like this:

    <input name="foo" value="<?php print htmlspecialchar s($foo)?>">

    where $foo contains the value that was entered in the text field before.
    [color=blue]
    ><form action="formtes t1.php?c=1" method=POST>
    > <b>Find Results with:
    > These words: <input type="text" length=40 name="keywords" >
    > input type="submit" value="Search">
    ></form>[/color]

    You could also try this:

    <form action="formtes t1.php?c=1" method="post">
    <label for="keywords"> Find results with these words:</label>
    <input name="keywords" id="keywords" length="40">
    <input type="submit" value="Search">
    </form>

    Labels make forms more accessible, especially when used for checkboxes
    and radio buttons.

    Micha

    Comment

    Working...