Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Linux, Apache, MySQL, PHP
  4. I can't get variables from forms

I can't get variables from forms

Scheduled Pinned Locked Moved Linux, Apache, MySQL, PHP
phphelp
4 Posts 4 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    blackhattrick
    wrote on last edited by
    #1

    For instance, I've got this form:

    Choose an Option: Option 1 Option 2 Option 3 Option 4

    And choseOption.php is like this: The form work fine but when I choose an option and submit it I get this The option selected was:'' It is supposed that variable $selectedOption is created implicitly but it does not print its value. As you can see, I'm starting in php and web programing, so I'm kind of lost. Any help would be appreciated and excuse my english. Regards Iván Cruz

    K M R 3 Replies Last reply
    0
    • B blackhattrick

      For instance, I've got this form:

      Choose an Option: Option 1 Option 2 Option 3 Option 4

      And choseOption.php is like this: The form work fine but when I choose an option and submit it I get this The option selected was:'' It is supposed that variable $selectedOption is created implicitly but it does not print its value. As you can see, I'm starting in php and web programing, so I'm kind of lost. Any help would be appreciated and excuse my english. Regards Iván Cruz

      K Offline
      K Offline
      Kristian Sixhoj
      wrote on last edited by
      #2

      blackhattrick wrote:

      echo ("The option selected was: '$selectedOption'");

      You can't get values from forms just like that. You need to get the value via the POST method:

      $selectedOption = $_POST['selectedOption'];

      echo ("The option selected was: '$selectedOption'");
      ?>

      That should work.

      Kristian Sixhoej


      "Failure is not an option" - Gene Kranz

      1 Reply Last reply
      0
      • B blackhattrick

        For instance, I've got this form:

        Choose an Option: Option 1 Option 2 Option 3 Option 4

        And choseOption.php is like this: The form work fine but when I choose an option and submit it I get this The option selected was:'' It is supposed that variable $selectedOption is created implicitly but it does not print its value. As you can see, I'm starting in php and web programing, so I'm kind of lost. Any help would be appreciated and excuse my english. Regards Iván Cruz

        M Offline
        M Offline
        Mohammad Dayyan
        wrote on last edited by
        #3

        See Predefined variables[^] for further information.

        1 Reply Last reply
        0
        • B blackhattrick

          For instance, I've got this form:

          Choose an Option: Option 1 Option 2 Option 3 Option 4

          And choseOption.php is like this: The form work fine but when I choose an option and submit it I get this The option selected was:'' It is supposed that variable $selectedOption is created implicitly but it does not print its value. As you can see, I'm starting in php and web programing, so I'm kind of lost. Any help would be appreciated and excuse my english. Regards Iván Cruz

          R Offline
          R Offline
          Ranjit Viswakumar
          wrote on last edited by
          #4

          When you POST variables, they are encapsulated in a $_POST array. Each value can be called by its key or $_POST['name of field']. In your example, $_POST['selectedOption'] would contain an integer 1-4. For more information, you can take a look at: http://www.w3schools.com/php/php_post.asp[^] Good luck! Ranjit Viswakumar Professional Services Specialist rviswakumar@hostmysite.com HostMySite.com[^]

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups