0

After the form is submit, it will not echo $genderRadio

Any ideas? It can select the gender but I can't display in the php file

`<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>

    <head>




        <title> Assignment 2</title>




    </head>


                <body> 


                        <h1>Please enter your information</h1>

                                <form method= "post" action = "output_hw2.php">
                                <table width="500">
                                <tr>
                                <td><strong>First Name:</strong> </td>
                                <td><input type= "text" name = "fname" /></td>
                                <tr/>
                                <tr>
                                <td><strong>Last Name:</strong></td>
                                <td><input type="text" name = "lname" /></td>
                                </tr>



                                <tr>
                                <td><strong>Gender:</strong></td> 
                                <td></td>
                                </tr>
                                <tr>
                                <td> <input type="radio" name = "genderRadio" value="Female" />Female</td>
                                </tr>
                                <td> <input type="radio" name = "genderRadio" value="Male"/>Male</td>
                                </tr>

                                <tr>
                                <td><strong>Address:</strong> </td>
                                <td><input type="text" name = "address" size="50"/></td>
                                </tr>

                                <tr>
                                <td><strong>City:</strong> </td>
                                <td><input type="text" name = "city" size="30"/></td>
                                </tr>


                                <tr>
                                <td><strong>State:</strong></td> 


                                <td><select name="state">
                                <option value=" ">Pick a state</option>
                                <option value="Ar">Arizona</option>
                                <option value="GA">Georgia</option>
                                <option value="TN">Tennessee</option></td>

                                </select>
                                </tr>
                                <tr>
                                <td><strong>Zip Code:</td>
                                <td></strong> <input type="text" name="zip" size= "5" /></td>
                                </tr>
                                </table>

                                <p><strong>Comments:</strong></p>
                                <textarea name="comments" rows="5" cols="40" ></textarea> <br/><br/>

                                <input type="submit" name="submit" value ="submit" /> <br/>

                                </form>

                </body>


    </html>

here is the php file:

<?php

$firstName = $_POST['fname'];
$lastName = $_POST['lname'];
$genderRadio = $_POST['genderRadio'];
$address = $_POST['address'];
$state = $_POST['state'];
$city = $_POST['city'];
$zip = $_POST['zip'];

echo "Thank You $firstName $lastName", "<br/>";
echo "<strong>This is what you entered </strong>: ". "<br/>";
echo "Address: <b>$address </b>". "<br/>";
echo "State: <b>$state</b> ". "City: <b>$city </b>". "Zip: <b>$zip</b> ". "<br/>";

echo "You are: $genderRadio ";
print "We are very please that you decided to submit your information. If you find anything
wrong please go back and re-enter the correct information and please post a comment
saying that you're correcting your information in addition to the comment you already
add(if you did alread or want to add one)";

?>
`

2
Contributors
1
Reply
3
Views
5 Years
Discussion Span
Last Post by broj1
0

I copied your code and the value of gender displays OK (if you chose one). Put a break after it in php file to make it more visible

echo "You are: $genderRadio<br />";

If the gender still does not get displayed print the whole $_POST array and see what it says (you can post the output here). Put this line in the beginning of the php file:

print_r($_POST);
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.