Session with CheckBox && Select Option
Please help me to store values from CheckBox and Select elements to Session variable. following is the code.
PHP Code:
<?php
// check1.php
session_start();
if(isset($_POST["major"], $_POST["minor"], $_POST["card"]))
{
$_SESSION["card"]=$_POST["card"];
$_SESSION["major"]=$_POST["major"];
$_SESSION["minor"]=$_POST["minor"];
}
?>
HTML Code:
<html>
<head>
<head>
<title>Check Box</title>
</head>
<body>
<form name="f" method="POST" action="<?php echo $_SERVER["PHP_SELF"]; ?>">
<select size="3" name="card">
<option name="card">One Card</option>
<option name="card">Two Cards</option>
<option name="card">Three Cards</option>
</select>
<br><br>
<input type="checkbox" name="major" value="Major">Major
<input type="checkbox" name="minor" value="Minor">Minor
<br><br>
<input type="button" name="b" value="Click" onclick="Redirect()">
</form>
</body>
<script language="javascript">
function Redirect()
{
location.href="check2.php";
}
</script>
</html>
PHP Code:
<?php
// check2.php
session_start();
echo $_SESSION["card"]."<br>";
echo $_SESSION["major"]."<br>";
echo $_SESSION["minor"]."<br>";
?>
Re: Session with CheckBox && Select Option
I am not sure why I bother taking the time to reply to your threads if you are just going to post the same question 5 minutes later:
http://www.vbforums.com/showthread.php?t=424941
Read my replies in that thread.
Re: Session with CheckBox && Select Option
I need to know how to recover values from select option and check option and store it in session variables. Previously I did not ask this question. So please try to help me.
Re: Session with CheckBox && Select Option
Code:
<script language="javascript">
function Redirect()
{
location.href="check2.php";
}
</script>
Do not submit for data, you need to change
Code:
<input type="button" name="b" value="Click" onclick="Redirect()">
to
Code:
<input type="submit" name="b" value="Click" >
you also need to close the Form tag.
Code:
<?php
// check1.php
session_start();
if(isset($_POST["major"], $_POST["minor"], $_POST["card"]))
{
$_SESSION["card"]=$_POST["card"];
$_SESSION["major"]=$_POST["major"];
$_SESSION["minor"]=$_POST["minor"];
}
?>
<html>
<head>
<title>Check Box</title>
</head>
<body>
<form name="f" method="POST" action="check1.php">
<select size="3" name="card">
<option name="card">One Card</option>
<option name="card">Two Cards</option>
<option name="card">Three Cards</option>
</select>
<input type="checkbox" name="major" value="Major">Major
<input type="checkbox" name="minor" value="Minor">Minor
<input type="submit" value="Submit"/>
</form>
</body>
</html>