Hi All…I’m trying to access form values, so that I can used them on other pages. Can anybody show me how I can access and carry the value of $username to my next(add.php) page..Below I attach my code
index.php (first page)
<form name="form1" method="post" action="logcheck.php">
<table width="200" border="0">
<tr>
<td colspan="2">Login</td>
</tr>
<tr>
<td width="87">Username</td>
<td width="103"><input name="username" type="text" id="username"></td>
</tr>
<tr>
<td>Password</td>
<td><input name="password" type="text" id="password"></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="Submit"></td>
</tr>
</table>
</form>
logcheck.php (second page)
<?php
session_start();
header("Cache-control: private");
$_SESSION['username'] = $_POST['username'];
$_SESSION['password'] = $_POST['password'];
$db = @mysql_connect('localhost', 'root') or die('could not connect to mysql db, the server return the error:'.mysql_error());
mysql_select_db("timelinesys",$db) or die('could not connect to mysql db, the server return the error:'.mysql_error());
$query = "select * from user where username='$username' and password='$password'";
$sql = mysql_query($query) or die(mysql_error());
$count = mysql_num_rows($sql);
$row = mysql_fetch_array($sql);
if ($count >= 1)
{
header('Location: add.php');
}
else
{
header('Location: loginfailed.php');
}
?>
add.php (third page)
<?php
session_start();
header("Cache-control: private");
$_REQUEST['username'] = $_SESSION['username'];
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body>
Welcome <? php echo $_SESSION['username']; ?>
<br>
</body>
</html>