User Tools

Site Tools


basic_form

Link to this comparison view

Next revision
Previous revision
basic_form [2019/06/10 11:10]
nmckillop created
basic_form [2019/09/10 11:06] (current)
nmckillop
Line 1: Line 1:
-==== Creating a basic HTML form ====+  * [[Getting Started|Back to Getting Started Overview]] 
 +  * [[Editing files|(previous) Getting Started Part 4: Editing files]] 
 + 
 +====== 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.
  
 <​code>​ <​code>​
Line 8: Line 15:
 </​code>​ </​code>​
  
-=== Adding some PHP code to dump the form conents ===+==== Adding some PHP code to dump the form conents ​====
  
 <​code>​ <​code>​
Line 17: Line 24:
 ?> ?>
 </​code>​ </​code>​
 +
 +
 +==== Full working example ====
 +
 +<​code>​
 +<​html>​
 +  <form method='​post'​ action=''>​
 +    <input type='​text'​ name='​forename'>​
 +    <input type='​submit'​ name='​say_hello'​ value='​Say hello'>​
 +  </​form>​
 +
 +  <?php
 +   ​if(!empty($_REQUEST['​forename'​])) {
 +     echo "Hello {$_REQUEST['​forename'​]}";​
 +   }
 +  ?>
 +</​html>​
 +</​code>​
 +
 +===== 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.
 +
 +<​code>​
 +<?php
 +error_reporting(E_ALL);​
 +ini_set("​display_errors",​ 1);
 +?>
 +</​code>​
 +
 +**Note:** We'll start with this, then explain how to make it not as full-of-errors :)
 +
 +  * [[Getting Started Part 6|(next) Getting Started Part 6: What's Next]]
basic_form.1560165030.txt.gz · Last modified: 2019/06/10 11:10 by nmckillop