axiom28 Posted December 15, 2016 Share Posted December 15, 2016 Good Day I might have accidentally posted this twice, sorry about that. Here is my query, I am teaching myself PHP going through the chapters in your book, all has gone well until the section on validating forms, in particular the validating of radio buttons. # script 2.3 handle_form.php Everything works as it should except when neither of the two radio buttons are selected, this code if (isset($_REQUEST['gender'])) { $gender = $_REQUEST['gender']; } else { $gender = NULL; } Does not seem to see "gender" as a result the "You forgot to enter your gender" message does not appear. I did thoroughly check my code, asked several PHP programmers I know and they all tell me it should work. So have I done something wrong, is there a bug in my version of PHP (5.5.12), if it helps I am using Wamp Server on my PC with Windows 10. Ian Link to comment Share on other sites More sharing options...
axiom28 Posted December 15, 2016 Author Share Posted December 15, 2016 It's me again, I cannot believe that I made such a stupid mistake, I took a second look at my post, and then a second look at my code, there is nothing wrong with the code in the book if you type it in correctly the whole statement to advise people that they had forgotten to enter their gender was there, here's the faulty part: if ($gender == "M") { echo '<p><b>Good day, Sir!</b></p>';} elseif ($gender == "F") { echo '<p><b>Good day, Madam!</b></p>';} else { '<p><b>You forgot to enter your gender</b></p>';} Can you see what I forgot to do duh! I forgot to put echo in front of that statement, so easy to be blind to such an obvious error, as a technician I learned always look for the obvious and keep it simple, this, until now, had not extended to my programming skills. I am posting this so that other newbie programmers don't fall into the same trap of looking for everything else except what is right in front of their nose. Ian Link to comment Share on other sites More sharing options...
Larry Posted December 16, 2016 Share Posted December 16, 2016 Happens to us all. Glad you figured it out and thanks for letting us know! Link to comment Share on other sites More sharing options...
Recommended Posts