Having Problems in passing the checkbox value to next page

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • manjunath1985
    New Member
    • Oct 2007
    • 7

    Having Problems in passing the checkbox value to next page

    Hi,
    I am really having problem in checkbox....
    i have a php page which displays the username retrieved from the database i want to create a checkbox for each username and pass the selected multiple checkbox value to another page after selecting any one of the option value from the select box and after clicking on "go" button.

    In option value i have links to go for particular page.


    Plz help me out........
    Its very urgent......
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    Heya, manjunath1985. Welcome to TSDN!

    What do you want your code to do? Give an example.
    What is your code doing that you don't want it to do? Give an example.
    What is your code *not* doing that it is supposed to? Give an example.

    Comment

    • manjunath1985
      New Member
      • Oct 2007
      • 7

      #3
      Originally posted by pbmods
      Heya, manjunath1985. Welcome to TSDN!

      What do you want your code to do? Give an example.
      What is your code doing that you don't want it to do? Give an example.
      What is your code *not* doing that it is supposed to? Give an example.
      here is the code[code=html]
      <input type="checkbox" name="candidate username" value="select[]">[/code]
      i want to put a checkbox for candidateuserna me retrieved from the database and pass the multiple username selected checkbox value to next page after i select
      <option value="send_sms .php"> and after pressing "go" button.
      but i am not able to view the checkbox value in the selected page.
      Last edited by pbmods; Oct 22 '07, 11:41 AM. Reason: Added CODE tags.

      Comment

      • manjunath1985
        New Member
        • Oct 2007
        • 7

        #4
        Problem in Checkbox value

        hi,
        i am having some serious problem with checkbox....

        here is the code
        <input type="checkbox" name="candidate username" value="select[]">
        i want to put a checkbox for candidateuserna me retrieved from the database and pass the multiple username selected checkbox value to next page after i select
        <option value="send_sms .php"> and after pressing "go" button.
        but i am not able to view the checkbox value in the selected page.

        Plz help me out....
        Its very urgent...

        Comment

        • JeremyMiller
          New Member
          • Sep 2007
          • 69

          #5
          Originally posted by manjunath1985
          and pass the multiple username selected checkbox value to next page after i select.
          Can you rephrase that so that it's more clear?

          Comment

          • manjunath1985
            New Member
            • Oct 2007
            • 7

            #6
            Originally posted by JeremyMiller
            Can you rephrase that so that it's more clear?
            I have retrieved some usernames as per the code in one page. but i want to put a checkbox for all usernames and pass the same to the next page through the <option value="send_smd .php"> and after clicking on "go" button.

            Comment

            • JeremyMiller
              New Member
              • Sep 2007
              • 69

              #7
              Oh, well you're totally confused. Try starting with this code:
              [html]
              <form method="post" action="send_sm s.php">
              <input type="checkbox" name="candidate username[]" value="dude's name"> Dude's Name<br />
              <input type="checkbox" name="candidate username[]" value="dudette' s name"> Dudette's Name<br />
              ... repeat as much as you want
              <input type="submit" value="Go" />
              </form>
              [/html]

              Then, in send_sms.php, you can do something like this:

              [php]
              <?php
              foreach ($_POST['candidateusern ame'] as $a_candidate) {
              //Do something for the candidate whose name is in $a_candidate.
              }
              ?>
              [/php]

              Because of how checkboxes work, only those which are checked will be in the array.

              Oh, and I have no idea what you're trying with the <option> tag, but it looks wrong.

              Comment

              • manjunath1985
                New Member
                • Oct 2007
                • 7

                #8
                Originally posted by JeremyMiller
                Oh, well you're totally confused. Try starting with this code:
                [html]
                <form method="post" action="send_sm s.php">
                <input type="checkbox" name="candidate username[]" value="dude's name"> Dude's Name<br />
                <input type="checkbox" name="candidate username[]" value="dudette' s name"> Dudette's Name<br />
                ... repeat as much as you want
                <input type="submit" value="Go" />
                </form>
                [/html]

                Then, in send_sms.php, you can do something like this:

                [php]
                <?php
                foreach ($_POST['candidateusern ame'] as $a_candidate) {
                //Do something for the candidate whose name is in $a_candidate.
                }
                ?>
                [/php]

                Because of how checkboxes work, only those which are checked will be in the array.

                Oh, and I have no idea what you're trying with the <option> tag, but it looks wrong.
                Hey i wil make it clear now, see i have a php page called viewdb.php, this page displays a usernames retrieved from the database so i want to put a checkbox for each of the username in viewdb.php and pass the selected check box value to another page called send_sms.php... ...

                Plz help me out with the code......
                Thank you for replying to my thread.....

                Comment

                • pbmods
                  Recognized Expert Expert
                  • Apr 2007
                  • 5821

                  #9
                  Heya, manjunath.

                  Checkboxes only appear in the submitted form when they are checked.

                  Comment

                  • pbmods
                    Recognized Expert Expert
                    • Apr 2007
                    • 5821

                    #10
                    Merged duplicate threads.

                    Comment

                    • manjunath1985
                      New Member
                      • Oct 2007
                      • 7

                      #11
                      How to pass variables between two PHP pages?

                      Hi,
                      I have created php page called sms.php which displays the username retrieved from the database through selecting checkbox.
                      Here is the code in sms.php:
                      [code=php]
                      <?php
                      foreach($_POST['check'] as $value) //here 'check' is the name of checkbox//
                      { //<input type =checkbox name=check[]
                      //value=<?$row['username']?>>//
                      $check_msg=$val ue;
                      echo "message sent to $check_msg";
                      }
                      ?>
                      [/code] this code displays the username selected from the previous page.
                      But i want to pass these variables to another page called demo.php from sms.php page and display the same.
                      Last edited by Atli; Nov 3 '07, 04:37 PM. Reason: Fixed [code] tags and changed thread title.

                      Comment

                      • Atli
                        Recognized Expert Expert
                        • Nov 2006
                        • 5062

                        #12
                        Hi.

                        You could use Sessions to do that.

                        Comment

                        Working...