Hi, I’m hoping someone can help me with my problem. Basically what I am trying to create is a log in system, whereas customers can log in to view their package details (address, billing number etc.) But i’m confused on how I can display a customers results based upon who has logged in.
So far I have 2 tables, one called userlogin and one called userinfo. Userlogin simply contains username and password data, whereas userinfo will contain all of the the customers information (address, billing number etc.). These two tables share a row with the same value, user_id. I have tryed to use MYSQL inner join and such, but i’m unsure where I am going wrong, and why I can’t return one users information, and it instead shows me all results, or none.
Here is the code for my 2 pages, first the log in page.
[php]<?php
// Use session variable on this page. This function must put on the top of page.
session_start();
$_SESSION[‘username’] = ‘Root’;
////// Login Section.
$Login=$_POST[‘Login’];
if($Login){ // If clicked on Login button.
$username=$_POST[‘username’];
$password=$_POST[‘password’]; // Encrypt password with md5() function.
// Connect database.
//connect
$con = mysql_connect(“","”,"******");
if (!$con)
{
die('Could not connect: ’ . mysql_error());
}
//datebase
mysql_select_db("******", $con);
// Check matching of username and password.
$result=mysql_query(“select * from userlogin where username=’$username’ and password=’$password’”);
if(mysql_num_rows($result)!=‘0’){ // If match.
session_register(“username”); // Craete session username.
header(“location:home.php”); // Re-direct to main.php
exit;
}else{ // If not match.
$message="— Incorrect Username or Password —";
}
} // End Login authorize check.
?>[/php]
and here is the home page (the page which will display the customers information).
[php]<?php
session_start();
if(isset($_SESSION[‘username’]))
?>
I understand that I might not have explained this well, or my code might not be very clean, but please any feedback, or questions you have for me will be greatly appreciated! Thank you!