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"



        <title> Assignment 2</title>



                        <h1>Please enter your information</h1>

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

                                <td> <input type="radio" name = "genderRadio" value="Female" />Female</td>
                                <td> <input type="radio" name = "genderRadio" value="Male"/>Male</td>

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

                                <td><strong>City:</strong> </td>
                                <td><input type="text" name = "city" size="30"/></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>

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

                                <textarea name="comments" rows="5" cols="40" ></textarea> <br/><br/>

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




here is the php file:


$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)";


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:

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.