axhi Posted July 2, 2007 Share Posted July 2, 2007 I have a POST object that I am trying to figure out how to work. this is on the agreement page <form method="GET" action="?order"> <div align="center"> <p>Yes I agree:<input type="radio" name"order[]" value="YES"/> </p> <p>No I do not agree: <input type="radio" name"order[]" value="NO"/> </p> <p> <input type="submit" value="Continue" /> </p> </div> </form> which links to the order page which contains this portion of the code: <? if($_GET['order[]'] == "YES") { // no username entered echo "You did not enter a name."; } else { echo "Hello, " . $_GET['order[]']; } ?> Am i doing this right? I have no idea i just know that it doesnt read right. Quote Link to comment Share on other sites More sharing options...
corillo181 Posted July 2, 2007 Share Posted July 2, 2007 with radio you do not need [] just add the value and the same name.. so it would be type=radio name=agrement value=yes type=radio name=agrement value=no echo $_post['agrement']; Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted July 2, 2007 Share Posted July 2, 2007 If you use square brackets in a form field name you must place them outside the _POST variables eg: $_POST['order'][0] - first radio button (YES) $_POST['order'][1] - second radio button (NO) Now with radio buttons there is no need to place square brackets after radio button names as radio buttons only submit 1 result. You only place square brackets after a form name if you want to group multiple fields together which will return multiple results, such as checkboxes. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.