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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.