Hi,
I am kind of new to php, and have run into a problem. Whenever I try to pass on values from one page to another, using hyperlink, the variables in the session don't carry on. Any ideas as to why? Variables get passed when I use header(location:) code in php.
Can anyone recommend ways that I can pass sensitive information with moderate security from one page to another?
Thank you
P.S.
I included the session_start() on the link page.
Link page
<?php
session_start();
?>
<html>
<body>
<?php echo "User:". $_SESSION['user']; ?>
<a href="Untitled-1.php">HOME</a>
</body>
</html>
Home page
<?php
session_start();
if(isset($_SESSION['user']))
{}
else
{
$_SESSION['user'] = "Anonymous";
//header("location:Untitled-1.php");
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<script type="text/javascript">
x()
{
<?php
session_destroy();
?>
}
</script>
<body>
<?php
echo "User:". $_SESSION['user'];
if ($_SESSION['user'] == "Anonymous")
{
echo
'<form id="form1" name="form1" method="post" action="check.php">
<input name="myusername" type="text" id="myusername" value="" size="45" />
<input name="mypassword" type="password" id="mypassword" value="" size="45" />
<input type="submit" name="button" id="button" value="Submit" />
</form>';
}
else
{
echo
'<form id="form2" name="form2" method="post" action="">
<input type="submit" name="button" id="button" value="Logout" onclick="x()" />
</form>';
}
?>
<a href="linnk1.php">link </a>
</body>
</html>