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...

Member Avatar for michelleradu

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'];
Member Avatar for rajarajan2017

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.