I have a code that when the user login his/her repcode will be seasion also or pass to the next page...but the user will only input username and password in the login page but in the next page his/her repcode is passed to ned page....can anyone help me...Im trying to figure it out it for 2 hours already...my head hurts...help me guys.
ex tb_name = 'id','name','username','password','repcode'
1st page:
<!DOCTYPE html>
<?php
ob_start();
session_start();
include('include/connect.php');
?>
<html>
<head>
<title>test</title>
</head>
<body>
<form action="" method="post">
<input type="text" name="username">
<input type="text" name="password">
<input type="hidden" name="repcode" value="<?php $repcode ?>">
<input type="submit" name="login" id="send" />
</form>
</body>
</html>
<?php
// Inialize session
if(isset($_POST['login'])){
$username=$_POST['username'];
$password=$_POST['password'];
// Include database connection settings
include('connection.php');
// Retrieve username and password from database according to user's input
$login = mysql_query("SELECT * FROM users WHERE username = '$username' and password = '$password'");
// Check username and password match
if (mysql_num_rows($login) == 1) {
// Set username session variable
$_SESSION['username'] = $_POST['username'];
$repcode1 = mysql_query("SELECT repcode FROM users WHERE username = '$username");
while($row = mysql_fetch_array($repcode1))
{
$repcode = $row['repcode'];
}
$_SESSION['repcode'] = $repcode;
// Jump to secured page
$stat="UPDATE users SET status='login'";
mysql_query($stat);
header('Location: home2.php');
}
else {
}
}
?>
2nd page:
<!DOCTYPE html>
<?php
ob_start();
session_start();
include('include/connect.php');
?>
<html>
<head>
<title>test</title>
</head>
<body>
<form method="get" >
<input type="text" name="username" value="<?php echo $_SESSION['username']; ?> "/>
<input type="text" name="repcode" value="<?php echo $_SESSION['repcode']; ?> "/>
</form></body>
</html>
I want to show the repcode of the user in the 2nd page but my current code it wont I need help please.