By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,490 Members | 1,417 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,490 IT Pros & Developers. It's quick & easy.

Having Problems in passing the checkbox value to next page

P: 7
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......
Oct 20 '07 #1
Share this Question
Share on Google+
11 Replies


pbmods
Expert 5K+
P: 5,821
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.
Oct 20 '07 #2

P: 7
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
Expand|Select|Wrap|Line Numbers
  1. <input type="checkbox" name="candidateusername" value="select[]">
i want to put a checkbox for candidateusername 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.
Oct 22 '07 #3

P: 7
hi,
i am having some serious problem with checkbox....

here is the code
<input type="checkbox" name="candidateusername" value="select[]">
i want to put a checkbox for candidateusername 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...
Oct 22 '07 #4

P: 69
and pass the multiple username selected checkbox value to next page after i select.
Can you rephrase that so that it's more clear?
Oct 22 '07 #5

P: 7
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.
Oct 22 '07 #6

P: 69
Oh, well you're totally confused. Try starting with this code:
[html]
<form method="post" action="send_sms.php">
<input type="checkbox" name="candidateusername[]" value="dude's name"> Dude's Name<br />
<input type="checkbox" name="candidateusername[]" 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['candidateusername'] 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.
Oct 22 '07 #7

P: 7
Oh, well you're totally confused. Try starting with this code:
[html]
<form method="post" action="send_sms.php">
<input type="checkbox" name="candidateusername[]" value="dude's name"> Dude's Name<br />
<input type="checkbox" name="candidateusername[]" 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['candidateusername'] 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.....
Oct 22 '07 #8

pbmods
Expert 5K+
P: 5,821
Heya, manjunath.

Checkboxes only appear in the submitted form when they are checked.
Oct 22 '07 #9

pbmods
Expert 5K+
P: 5,821
Merged duplicate threads.
Oct 22 '07 #10

P: 7
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:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. foreach($_POST['check'] as $value) //here 'check' is the name of checkbox//
  3. {                                                  //<input type =checkbox name=check[]
  4.                                                                //value=<?$row['username']?>>//
  5. $check_msg=$value;
  6.  echo "message sent to $check_msg";
  7. }
  8. ?>
  9.  
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.
Nov 3 '07 #11

Atli
Expert 5K+
P: 5,058
Hi.

You could use Sessions to do that.
Nov 3 '07 #12

Post your reply

Sign in to post your reply or Sign up for a free account.