PHP HTML TextBox

From CoderLearner
Jump to: navigation, search

PHP works with HTML Input Text

HTML input tag with the type text is for single line input text.

Syntax input

<input type="text" name="name" value="the value" size="33" maxlength="33" />

Example 1

<?php
if ($_POST) {
   foreach ($_POST as $name => $value) {
      echo $name . '=' . $value . '<br/>';
   }
}
?>
<html>
   <head>
      <title>Text Input</title>
   </head>
   <body>
      <form method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>">
         <table>
            <tr>
               <td>Name</td>
               <td>
                  <input type="text" name="name" size="19" maxlength="20"/>
               </td>
            </tr>
            <tr>
               <td>Age</td>
               <td>
                  <input type="text" name="age" size="3" maxlength="3" value="5"/>
               </td>
            </tr>
            <tr>
               <td>Address-1</td>
               <td>
                  <input type="text" name="address1" size="19" maxlength="25"/>
               </td>
            </tr>
            <tr>
               <td>Address-2</td>
               <td>
                  <input type="text" name="address2" size="19" maxlength="25"/>
               </td>
            </tr>
            <tr>
               <td></td>
               <td><input type="submit" name="checkout"/></td>
            </tr>
         </table>
      </form>
   </body>
</html>

Try It