1. <HTML>
  2. <HEAD>
  3. <TITLE>Form Series - Example One</TITLE>
  4. </HEAD>
  5. <BODY>
  6. <B>
  7. <H2>Form Series - Example One</H2>
  8. <?PHP
  9. empty($FirstPass) ? # First pass if empty
  10. ShowForm() : # Display the form
  11. ShowResults($FirstName,$LastName,nl2br($Comments));
  12. exit;
  13. ?>
  14. <?PHP
  15. function ShowResults ($First, $Last, $Answer) {
  16. global $HTTP_USER_AGENT;
  17. echo "Thanks $First $Last
  18. <BR>
  19. Your comment of
  20. <BR>
  21. <FONT COLOR=\"RED\" SIZE=\"+1\">
  22. $Answer
  23. </FONT>
  24. <BR>
  25. is appreciated.
  26. <P>
  27. Pleased to see you are using:
  28. <BR>
  29. <FONT COLOR=\"BLUE\" SIZE=\"+1\">
  30. $HTTP_USER_AGENT
  31. </FONT>
  32. <H2>Dump of GLOBALS Array</H2>
  33. <UL>\n";
  34. foreach ($GLOBALS as $Key=>$Value){
  35. echo "<LI>\$GLOBALS[\"$Key\"]=$Value\n";
  36. } # End of foreach ($GLOBALS as $Key=>$Value)
  37. echo "</UL>\n";
  38. } # End of function ShowResults
  39. function ShowForm() {
  40. global $PHP_SELF; # The path and name of this file
  41. $HTML=<<<HTML
  42. <FORM ACTION="$PHP_SELF">
  43. <INPUT TYPE="HIDDEN" NAME="FirstPass" VALUE="No">
  44. Your First Name: <INPUT TYPE="Text" NAME="FirstName">
  45. <BR>Your Last Name: <INPUT TYPE="Text" NAME="LastName">
  46. <BR>What do you think about PHP?
  47. <BR><TEXTAREA COLS="40" ROWS="4" NAME="Comments"></TEXTAREA>
  48. <BR><INPUT TYPE="Submit" VALUE="Submit Now">
  49. </FORM>
  50. </B>
  51. </BODY>
  52. </HTML>
  53. HTML;
  54. echo $HTML;
  55. } # End of function ShowForm
  56. ?>