Jump to content
Larry Ullman's Book Forums

oddlaw

Members
  • Posts

    2
  • Joined

  • Last visited

Posts posted by oddlaw

  1. I am also having an issue with this.....

     

    both of the forms work w/o error but when i run handle_form.php the variable values are blank. if i run form.html i have all the fields but when i click submit it does nothing.

     

    i checked like it says in the book for the proper capitalization of the variables, but my text editor would tell me if the $_REQUEST is wrong or not. every other script has worked up to this point and i'm not sure what is going on.

     

    my code for the form.html is as follows:

     

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

    <html>

    <head>

    <meta http-equiv="Content-Type" content="text/html; charset-utf-8" />

    <title>Simple HTML Form</title>

    <style type="text/css" title="text/css" media="all">

    label {

    font-weight: bold;

    color: #300ACC;

    }

    </style>

    </head>

    <body>

    <!-- Script 2.1 - form.html -->

     

    <form action-"handle_form.php"method="post">

     

    <fieldset><legend>Enter your information in the form below:</legend>

     

    <p><label>Name: <input type="text"name="name" size="20" maxlength="40" /></label></p>

     

    <p><label>Email Address: <input type="text" name="email" size="40" maxlength="60" /></label></p>

     

    <p><label for="gender">Gender:</label><input type="radio" name=gender value="M" /> Male <input type="radio" name="gender"value="F" /> Female</p>

     

    <p><label>Age:

    <select name="age">

    <option value="0-29">Under 30</option>

    <option value="30-60">Between 30 and 60</option>

    <option value="60+">Over 60</option>

    </select></label></p>

     

    <p><label>Comments: <textarea name="comments" rows="3" cols="40"></textarea></label></p>

     

    </fieldset>

     

    <p align="center"><input type="submit" name="submit" value="Submit My Information" /></p>

     

    </form>

     

    </body>

    </html>

     

     

     

    my code for the form_handle.php is:

     

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

    <html>

    <head>

    <meta http-equiv="Content-Type" content="text/html; charset-utf-8" />

    <title>Form Feedback</title>

    </head>

    <body>

    <?php # Script 2.2 - handle_form.php

     

    //Create a shorthand for the form data:

    $name = $_REQUEST['name'];

    $email = $_REQUEST['email'];

    $comments = $_REQUEST['comments'];

    /* Not used:

    $_REQUEST['age']

    $_REQUEST['gender']

    $_REQUEST['submit']

    */

     

    //Print the submitted information:

    echo "<p>Thank you, <b>$name</b>, for the following comments:<br />

    <tt>$comments</tt></p>

    <p>We will reply to you at <i>$email</i>.</p>\n";

     

    ?>

    </body>

    </html>

×
×
  • Create New...