I'm trying to build a web app just to learn php. The main screen is a user logon screen when the user logs on it authenticates it though mySQL. The next screen is like a user screen. Well lets say the user wants to create a new customer, so there is a link to a new page to create a new customer. Well on the new customer page there is a link back to the main user screen. I'm using cookies to make sure its all working and I am able to output the cookies on the 3rd page for the user information, so I know its working. I just don't know how to get the user information back to the main user screen. I'll just show the code.
Logon screen form.
<form method="post" action="userlogon.php">
<center>User Name: <center><input name="username" type="text" /></center></center><br />
<center>Password: <center><input name="password" type="password" /></center></center><br />
<center><input type="submit" name="submitinfo" value="Submit"></center></form>
<?php
$link = mysql_connect('host','root','pass')
or die("you fail");
mysql_select_db("dbname");
session_start();
$_SESSION['username'] = $_POST['username'];
$_SESSION['password'] = $_POST['password'];
$username = $_POST['username'];
$password = $_POST['password'];
if($username=="" || $password=="")
{
die("Please do not leave the username / password field blank!");
}
$result = mysql_query("SELECT * FROM users WHERE
username='$username' AND password='$password'");
$number = mysql_num_rows($result);
if($number==0)
{
die("Your login details are not right. Please click the back button
and correct them.");
}
?>
New customer screen.
<?php
session_start();
$user = $_SESSION['username'];
$pass = $_SESSION['password'];
<a href="userlogon.php">Main Screen</a>
When I click on the link on the 3rd page I get this
"Please do not leave the username / password field blank!"
I understand that it should not work, I have thought about using a hidden form, but not sure how to go about doing that.
Is there maybe a tutorial somewhere about users logging on and how to pass variables so that only users can get to screens after the main logon screen?
I help would be appreciated.