DEV Community

Cover image for PHP form 45: input text textarea select-multiple
Falah Al Fitri
Falah Al Fitri

Posted on • Edited on

PHP form 45: input text textarea select-multiple


Happy Coding



Previous

We will create form with type select multiple input:

    <form method="post" action="process.php" >

        Firstname: <input type="text" name="firstname" />
        <br />

        Lastname: <input type="text" name="lastname" />
        <br />

        Description: <textarea name="description" rows="10" cols="50"></textarea>
        <br />
Enter fullscreen mode Exit fullscreen mode

Add input type select with:

  1. It name in array postfix []
  2. Set attribute multiple
  3. Set attribute size; default size='4' (options)
        Programming Language (multi): (hold ctrl + click item)
        <select name="languages[]" multiple size="5" >
            <option value="c" >C</option>
            <option value="c++" >C++</option>
            <option value="java" >Java</option>
            <option value="javascript" >Javascript</option>
            <option value="php" selected >PHP</option>
        </select>
Enter fullscreen mode Exit fullscreen mode

        <br />

        <hr />

        <input type="submit" name="submit" value="Submit" />

    </form>
Enter fullscreen mode Exit fullscreen mode

And, the process:

    echo "<pre>";

    var_dump($_POST);
Enter fullscreen mode Exit fullscreen mode

Source Code Next


Thank for reading :)

Top comments (0)