Closed Thread Icon

Topic awaiting preservation: PHP: Retriving Radio Button values? (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=23563" title="Pages that link to Topic awaiting preservation: PHP: Retriving Radio Button values? (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: PHP: Retriving Radio Button values? <span class="small">(Page 1 of 1)</span>\

 
Fikzy
Nervous Wreck (II) Inmate

From:
Insane since: Aug 2004

posted posted 10-06-2004 16:14

I need help on how to retrieve the value from HTML Radio button, and then to store it in the Sesion.

my code looks like :

<?php
session_start();
$message = "";
if (isset($_POST['submit'])) {
$_SESSION['cgender'] = $_POST['cgender'];
header("location:education_1.php");

}
?>
<form name="form1" method="post" action="<?=$_SERVER['PHP_SELF'] ?>">
Male<input type="radio" name="cgender" value="Male">
Females <input type="radio" name="cgender" value="Female"></td>
<input type="submit" name="submit" id="submit" value=">> CONTINUE >>">
</form>

but its not working...
-Help
-Fikayo

Tyberius Prime
Paranoid (IV) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 10-06-2004 16:18

well. Start off by escaping > and < that do not belong to tags with &gt; and &lt; (search for html entities).
So... which part is not working? Are you not being redirected? Check the faq on 'redirect php'. Or is your session variable not being set?
What do you see if you do var_dump($_POST) instead of just assigning it to a session variable?

so long

->Tyberius Prime

Fikzy
Nervous Wreck (II) Inmate

From:
Insane since: Aug 2004

posted posted 10-06-2004 16:43

This one works!

code:
<?php 
session_start();
if (isset($_POST['submit']) && isset($_POST['cgender'])) {

$_SESSION['cgender'] = $_POST['cgender'];
var_dump($_POST);
//header("location:education_1.php");

}
?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>

<form name="form1" method="post" action="<?=$_SERVER['PHP_SELF'] ?>">
Male<input type="radio" name="cgender" value="Male">
Females <input type="radio" name="cgender" value="Female"></td>
<input type="submit" name="submit" id="submit" value=">> CONTINUE >>">
</form>

</body>
</html>



-Real
-Fikzy

kronk
Paranoid (IV) Inmate

From: Sydney, Autralia
Insane since: Jun 2004

posted posted 10-09-2004 20:37

its a good idea to get into the habit of using correct syntax.

any self contained tag should be closed in itself, by that i mean

code:
<input typ="radio" name="whatever" value="whatever" />

<br />

<hr />

<img src="some_link" alt="some text" />



this will make your pages valid XHTML 1.1

---------------------------------------------------------------------------------------------------------------------
10/6 Web Solutions

New site online now!

For all your business and commercial web site needs.

Contact 10/6 Web Solutions today for an evaluation of your requirements.

« BackwardsOnwards »

Show Forum Drop Down Menu