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. Link to comment https://forums.phpfreaks.com/topic/58119-agreement-code-help/ 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']; Link to comment https://forums.phpfreaks.com/topic/58119-agreement-code-help/#findComment-288227 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. Link to comment https://forums.phpfreaks.com/topic/58119-agreement-code-help/#findComment-288238 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.