User Tools

Site Tools


Getting Started Part 5: Basic HTML Form

Creating a basic HTML form

Create a new file on your server called form.php and enter this code. Visit it in your browser and see the result.

<form method='post' action=''>
<input type='text' name='search_keyword'>
<input type='submit' name='search_button' value='Search'>

Adding some PHP code to dump the form conents

echo "<pre>";
echo "</pre>";

Full working example

  <form method='post' action=''>
    <input type='text' name='forename'>
    <input type='submit' name='say_hello' value='Say hello'>

   if(!empty($_REQUEST['forename'])) {
     echo "Hello {$_REQUEST['forename']}";

Error reporting

Add this to the very top of your file to enable error reporting and see how that changes the output of your form.php file.

ini_set("display_errors", 1);

Note: We'll start with this, then explain how to make it not as full-of-errors :)

coding/basic_form.txt · Last modified: 2023/06/26 02:22 by admin