Building Chinese Web Sites using PHP
Dr. Herong Yang, Version 2.11

Processing Web Form Input in ASCII

This section describes how to display a Web form and process form input data in ASCII.

To show you how Web form input data can be processed with a PHP script, I wrote this short test script to display a simple Web form, and process the for input in one script:

<?php #Web-Form-Input-ASCII.php
# Copyright (c) 2007 by Dr. Herong Yang, http://www.herongyang.com/
#
  print('<html>');
  print('<body>'."\n");

# Default input text
  $input = "Television";

# Form reply determination
  $reply = isset($_REQUEST["Submit"]);

# Process form input data
  if ($reply) {
    if (isset($_REQUEST["Input"])) {
      $input = $_REQUEST["Input"];
    }
  }

# Display form
  print('<form>');
  print('<input type="Text" size="40" maxlength="64"'
   . ' name="Input" value="'.$input.'"/><br/>');
  print('<input type="Submit" name="Submit" value="Submit"/>');
  print('</form>'."\n");

# Display reply
  if ($reply) {
    print('<pre>'."\n");
    print('You have submitted:'."\n");
    print('  Text = '.$input."\n");
    print('</pre>'."\n");
  } 

  print('</body></html>');
?>

After moving this PHP script file to Apache server document directory, I tested it with Internet Explorer (IE) with this URL: http://localhost/Web-Form-Input-ASCII.php. I saw a Web page with a form that has the suggested input value and a submit button.

After clicking the submit button, I saw a returning Web page with the same form and a reply section, which confirmed that the input text were correctly received by the PHP script.
Processing Web Form Input in ASCII

Sections in This Chapter

Steps and Components Involved

Processing Web Form Input in ASCII

Processing Web Form Input in Latin1

Entering Latin1 Characters with Alt Keycodes

Testing Latin1 Alt Keycodes with IE

Processing Web Form Input in UTF-8

Outputting Form Default Input Text in UTF-8

Testing Alt Keycodes with IE on a UTF-8 Web Page

Dr. Herong Yang, updated in 2007
Processing Web Form Input in ASCII