Jump to content

using _post


desjardins2010

Recommended Posts

hey guys

I know this is html but I'm using the php $_POST to grab the information the user chooses, i can't figure out though how to grab the info i'm looking for in this select option form

if they choose PasswordCracker v3.0 what is it i'm looking to set my $_post['']; to?

<FORM action="buy.php" method="POST">
    <select name="passwordcrakers">
      <option value="v2.0">PasswordCracker V2.0</option>
      <option value="v3.0">PasswordCracker V3.0</option>
      <option value="v4.0">PasswordCracker V4.0</option>
      <option value="v5.0">PasswordCracker V5.0</option>
      <option value="v6.0">PasswordCracker V6.0</option>
      <option value="v7.0">PasswordCracker V7.0</option>
      <option value="v8.0">PasswordCracker V8.0</option>
      <option value="v9.0">PasswordCracker V9.0</option>
      <option value="v10">PasswordCracker V10</option>
        </select><br />
	<input type="submit" value="Buy" name="submit" />
	</FORM>

Link to comment
Share on other sites

No, $_POST['v3.0']; is wrong, there is no field called v3.0 is there, the field is called passwordcrackers and the value would be the v3.0 if that was selected. it should be

 

$version = $_POST['passwordcrackers'];

 

// $version would be v2.0 or v3.0 etc, depending on which option was selected from the dropdown

 

if($version == 'v3.0')

{

  // user selected version 3.0

}

Link to comment
Share on other sites

oh blimey sorry desjardins2010, really wasn't thinking straight there. Think i was assuming you were looking to do something if the user selected "v3.0":

 

if(isset($_POST['submit']))
  {
    if($_POST['passwordcrackers'] == 'v3.0')
      {
         .... do or set set something
      }
    elseif(...something else)
      {
      }
   }

 

... my bad too much xmas food

Link to comment
Share on other sites

Don't use if(isset($_POST['submit'])) to test if a form has been submitted. Use:

 

if($_SERVER['REQUEST_METHOD'] == 'POST')

{

    // form is submitted

}

 

Using the isset way will mean that if the user presses the enter key to submit the form with internet explorer, your code will not pickup the fact that the form has been submitted.

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.