0

hi all,
i dont know what the error with this program.I cannot get the value.

-----sample.php---

<?php
ob_start();
@session_start();
require_once ("damn.php");
createsessions(sex);
?>
<html>
<body>
<form action="sample2.php" method="post">
<input type="radio" name="sex" value="male" /> Male
<br />
<input type="radio" name="sex" value="female" /> Female
<input type="submit" name="Submit"  value="Submit">
</form>
</body> 
</html>

-----sample2.php----

<?php
  $sex=$_SESSION[sex];
  echo $sex;
?>

----damn.php---

<?php
function createsessions($sex)
{
    session_register();
    $_SESSION["sex"] = $sex;
}
?>

wen i press submit button i am not getting the echo value i am not knowing wer the error is....? so can any one...?
thanks in advance...

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by rajarajan07
0

In sample2.php you should get the chosen value in the form using POST.
So instead of

$sex=$_SESSION[sex];

you should have

$sex=$_POST['sex'];
0

I really not have the technical knowledge of sessions, but above reply will show you the echo. But ensure that you have written right code for session. I think session_register need atleast one argument.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.