Jump to content

agreement code help


axhi

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.