 | PHP Radio Button Email Help, Verify Password | |
June 25th, 2003, 09:41 PM
|
#1 (permalink)
| | Ultimate Member
Join Date: Dec 2002 Location: Fayetteville, NC
Posts: 1,385
| PHP Radio Button Email Help, Verify Password
I am new to PHP and have just coded my first form handler. I got everything to work just fine except when trying to get the radio button choices to come to my email box.
Here is what I have for my form radio buttons:
Do you want a phpBB board?<br>
<input name="phpBByes" type="radio" id="phpBByes" value="<? echo $phpBByes; ?>">Yes
<input name="phpBBno" type="radio" id="phpBBno" value="<? echo $phpBBno; ?>">No
<br><br>
I've got it carrying these variables in the email script:
phpBB: $phpBByes $phpBBno
It will just display nothing in its place. How can I get it to show up?
Also, I would like to know how to make it so you have the verify password box like if your passwords don't match it will tell you.
Thanks!  |
| |
July 7th, 2003, 09:51 PM
|
#2 (permalink)
| | Ultimate Member
Join Date: Oct 2001 Location: Arizona
Posts: 2,538
|
You must use the same "name" for radio buttons. Choose something like phpBBask. PHP Code: if($userpassword != $userpassword2) {
echo "Your desired password and retyped password do not match"
};
Someone may have a better way, but that's what comes to my mind. |
| |
July 7th, 2003, 11:24 PM
|
#3 (permalink)
| | Banned
Join Date: Oct 2001
Posts: 447
| Quote: |
You must use the same "name" for radio buttons.
| radio buttons are exclusive, can only choose one. In PHP, will return value of radio button selected.
If you want the user to have more choices, use checkbox.
for PHP:
<input type=checkbox name=choices[]...
in PHP, you now have array of choices... |
| |
July 8th, 2003, 02:46 AM
|
#4 (permalink)
| | Ultimate Member
Join Date: Oct 2001 Location: Arizona
Posts: 2,538
|
Well it's a yes or no question. In order to return the correct value for the selection, the radio button has the have the same "name", but values can be different (they have to be). |
| |
July 8th, 2003, 08:08 AM
|
#5 (permalink)
| | Ultimate Member
Join Date: Dec 2002 Location: Fayetteville, NC
Posts: 1,385
|
Well, I have the form so it has this on it: PHP Code:
<input name="phpBB" type="radio" id="phpBB" value="<? echo $phpBByes; ?>">Yes
<input name="phpBB" type="radio" id="phpBB" value="<? echo $phpBBno; ?>">No Then in the processor I have it posting: PHP Code: $phpBB = $_POST['phpBB'];
Then: PHP Code: $phpBB = stripslashes($phpBB);
Then: Then: PHP Code: if(!$phpBB){
echo "Whether you want phpBB or not this is required. Please select yes or no below.<br />";
}
Then I include the form. Then I exit.
Lastly I have my email form and it shows the variable of this: $phpBB
How would I get the password validation thing if I already use that method to check for fields not being filled out?
Thanks for the responses. |
| |
July 9th, 2003, 12:34 AM
|
#6 (permalink)
| | Banned
Join Date: Oct 2001
Posts: 447
| Quote: |
In order to return the correct value for the selection, the radio button has the have the same "name", but values can be different (they have to be).
| can be, or have to be?
Depending on version of PHP, I think (can try later...):
In PHP, will return value of radio button selected.
anyway, what are the values of $phpBByes and $phpBBno when form is created. Then, regardless of either choice, what is returned from form input? |
| |
July 10th, 2003, 02:09 AM
|
#7 (permalink)
| | Ultimate Member
Join Date: Dec 2002 Location: Fayetteville, NC
Posts: 1,385
| |
| |
July 10th, 2003, 02:41 AM
|
#8 (permalink)
| | Ultimate Member
Join Date: Oct 2001 Location: Arizona
Posts: 2,538
|
He means the values have to be different. It's pointless sending the same value across for both choices. |
| |
July 10th, 2003, 02:54 AM
|
#9 (permalink)
| | Ultimate Member
Join Date: Dec 2002 Location: Fayetteville, NC
Posts: 1,385
|
The values are $phpBByes & $phpBBno. And from what that looks like to me...it is different. |
| |
July 10th, 2003, 10:03 PM
|
#10 (permalink)
| | Banned
Join Date: Oct 2001
Posts: 447
| Quote: |
The values are $phpBByes & $phpBBno.
| No. The variables are named $phpBByes & $phpBBno. The values of the variables is what actually gets placed into the HTML form. So determine what the values are placed in the form during script execution. Easy way, run the PHP script in browser, do a view source. Better way, debug the PHP script, as in.
print "BByes= ". $phpBByes;
print "BBno= ". $phpBBno;
//then code for HTML form
Then in handler:
print "form post val = ". $_POST['phpBB'];
.....
Wonder if:
if((!$phpBB)){
is even applicable, as return should be string (value attribute of form element), not boolean???
Don't have my PHP code handy, else, could tell you...
Last edited by qball : July 10th, 2003 at 10:05 PM.
|
| | | Most Active Discussions | | | | | Recent Discussions  | | | | | | | | Thread Tools | Search this Thread |
| | |
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) |
| |