How to display HTML forms in a module

21.12. How to display HTML forms in a module

When you have HTML forms in a module, you may run into problems with passing the values from the form fields to the module itself. Here is just a simple form that you can use as a starting point for your own module with forms - just make a folder named Testing (for instance) in your modules folder, and put an index.php in it with the following code (see File doesn't exist error when posting with a form):

if (!eregi("modules.php", $PHP_SELF)) {
  die ("You can't access this file directly...");
$module_name = basename(dirname(__FILE__));
echo "<center><form action=\"modules.php?name=$module_name\" method=\"post\"> "
."Name: <input type=\"text\" name=\"yourname\" size=\"20\" 
."<input type=\"hidden\" name=\"test_input\" value=\"test is good\">"
."<input type=\"submit\" value=\"Submit\"></form></center>";
if($test_input != "") {
  echo "<br>Form worked, and yourname is $yourname";

Site Info v2.2.2

Last SeenLast Seen
Server TrafficServer Traffic
  • Total: 350,120,009
  • Today: 61,145
Server InfoServer Info
  • Mar 23, 2018
  • 03:34 pm PDT

Daily Inspiration