For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > October 2006 > radio buttons









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author radio buttons
Shelly

2006-10-12, 6:58 pm

I have used radio buttons often in the past, but now I am having problems.
Please, someone, look at this simple code and tell me where I am going
wrong. I cannot retrieve the posted value of gender when I click either
button (male or female)

I have tried (in desperation)
1 - removing the target statement on the form.
2 - adding [] to become name="gender[]".
3 - changing the values to 1 and 2.

Nothing is working. It must be something extremely simple and obvious, but
I just can't see it.

This has worked for me many times in the past. Does anyone see ANYTHING?
The complete code is below between the "******" lines, and can be cut and
pasted.

Shelly

*******************************
<?php
if (isset($_POST['update'])) {
$gender = $POST['gender'];
echo "gender=" . $gender . "<br>";
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>

<body>
<form action="" method="post" name="properties" TARGET="_SELF">
<table>
<tr>
<td>Male<input type="radio" name="gender" value="M">  
Female<input type="radio" name="gender" value="F"></td>
</tr>
<tr align="center">
<td colspan="2"><input type="submit" name="update" value="Update"></td>
</tr>
</table>
</form>
</body>
</html>
*********************************


Chuck Anderson

2006-10-12, 6:58 pm

Shelly wrote:
> I have used radio buttons often in the past, but now I am having problems.
> Please, someone, look at this simple code and tell me where I am going
> wrong. I cannot retrieve the posted value of gender when I click either
> button (male or female)
>
> I have tried (in desperation)
> 1 - removing the target statement on the form.
> 2 - adding [] to become name="gender[]".
> 3 - changing the values to 1 and 2.
>
> Nothing is working. It must be something extremely simple and obvious, but
> I just can't see it.
>
> This has worked for me many times in the past. Does anyone see ANYTHING?
> The complete code is below between the "******" lines, and can be cut and
> pasted.
>
> Shelly
>
> *******************************
> <?php
> if (isset($_POST['update'])) {
> $gender = $POST['gender'];
> echo "gender=" . $gender . "<br>";
> }
> ?>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
> "http://www.w3.org/TR/html4/loose.dtd">
> <html>
> <head>
> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
> <title>Untitled Document</title>
> </head>
>
> <body>
> <form action="" method="post" name="properties" TARGET="_SELF">
> <table>
> <tr>
> <td>Male<input type="radio" name="gender" value="M">  
> Female<input type="radio" name="gender" value="F"></td>
> </tr>
> <tr align="center">
> <td colspan="2"><input type="submit" name="update" value="Update"></td>
> </tr>
> </table>
> </form>
> </body>
> </html>
> *********************************
>
>
>

I hope you don't have a gun nearby or you might shoot yourself.

if (isset($_POST['update'])) {
$gender = $POST['gender'];

You're missing the '_' in $POST['gender'].

--
*****************************
Chuck Anderson • Boulder, CO
http://www.CycleTourist.com
*****************************
Shelly

2006-10-12, 6:58 pm


"Chuck Anderson" <websiteaddress@seemy.sig> wrote in message
news:EJadnZUBNN_8drfYnZ2dnUVZ_oWdnZ2d@co
mcast.com...
> I hope you don't have a gun nearby or you might shoot yourself.
>
> if (isset($_POST['update'])) {
> $gender = $POST['gender'];
>
> You're missing the '_' in $POST['gender'].


BOOM!!!!! I knew it had to be something stupid and obvious. Thanks. By
the way, this didn't work so well when I had "M" and "F" as the values, but
worked properly with "1" and "2". In the past I had always used numbers.
Curious?????

Shelly


flamer die.spam@hotmail.com

2006-10-12, 6:58 pm


Shelly wrote:

> "Chuck Anderson" <websiteaddress@seemy.sig> wrote in message
> news:EJadnZUBNN_8drfYnZ2dnUVZ_oWdnZ2d@co
mcast.com...
>
> BOOM!!!!! I knew it had to be something stupid and obvious. Thanks. By
> the way, this didn't work so well when I had "M" and "F" as the values, but
> worked properly with "1" and "2". In the past I had always used numbers.
> Curious?????
>
> Shelly


case-sensitive.

Flamer.

.:[ ikciu ]:.

2006-10-12, 6:58 pm

Hmm Shelly <sheldonlg.news@asap-consult.com> wrote:
> always used numbers. Curious?????


before compare try to use strtoupper or strtolower

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~
Ikciu | gg: 718845 | yahoo: ikciu_irsa | www: www.e-irsa.pl

2be || !2be $this => mysql_query();


Pedro Graca

2006-10-12, 6:59 pm

["Followup-To:" header set to comp.lang.php.]
Shelly wrote:
>
> "Chuck Anderson" <websiteaddress@seemy.sig> wrote in message
> news:EJadnZUBNN_8drfYnZ2dnUVZ_oWdnZ2d@co
mcast.com...
[...][color=darkred]
>
> BOOM!!!!!


For your next script try upping the error reporting of PHP

<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');

$x = $_POST['x'];
$y = $POST['y'];

// ...
?>

--
File not found: (R)esume, (R)etry, (R)erun, (R)eturn, (R)eboot
Shelly

2006-10-12, 6:59 pm


<die.spam@hotmail.com> wrote in message
news:1160453154.627178.61680@h48g2000cwc.googlegroups.com...
>
> Shelly wrote:
>
>
> case-sensitive.


I was using capitals all the way. I used "M" and "F", never "m" or "f". I
am careful about case. I just went back and tried it again with a second
test script and this time it worked fine with "M" and "F",

Shelly

Shelly


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com