This topic has been covered at some length on these forums. I know this because I have read pretty much every article. Unfortunately I still haven't found an answer that helps me. So here goes.
I have a basic login page that checks for a username and password from a mysql database and redirects to the current hompage. It works like a charm, but now I need to be able to redirect a user to their own idividual page of the website based on their user name and password. I've seen this done with an IF statement but it usually assumes only a few users, I will have at least 20 to start and much more over the next year. If someone could point me in the right direction a would be most appreciatve. I've seen several posts that tell you what to do but no code examples, so if someone could post some code or a link to some code that would be a lot of help too. Below is my current Login.php page.
<?php
/ Program: Login Page
Desc: Displays the login page for SKC Limited Clients.
*/
session_start();
include("./skclmtd_log.php");
switch (@$_GET['do'])
{
case "login":
$connection = mysql_connect($host, $user, $password)
or die ("Couldn't connect to server.");
$db = mysql_select_db($database, $connection)
or die ("Couldn't select database.");
$sql = "SELECT loginName FROM Member
WHERE loginName='$POST[fusername]'";
$result = mysql_query($sql)
or die("Couldn't execute query");
$num = mysql_num_rows($result);
if ($num == 1) //login name was found
{
$sql = "SELECT loginName FROM Member
WHERE loginName='$POST[fusername]'
AND password='$POST[fpassword]'";
$result2 = mysql_query($sql)
or die("Couldn't execute query 2.");
$num2 = mysql_num_rows($result2);
if ($num2 > 0) //password is correct
{
$SESSION['auth']="yes";
$logname=$POST['fusername'];
$SESSION['logname'] = $logname;
$today = date("Y-m-d hⓂs");
$sql = "INSERT INTO Login (loginName, loginTime)
VALUES ('$logname','$today')";
mysql_query($sql) or die("Couldn't execute query/");
header("Location: ./index.php");
}
else //password is not correct
{
unset($GET['do']);
$message="The Login Name, '$POST[fusername]'
exists, but you have not entered the
correct password! Please try again.<br>";
include("login_form.inc");
}
}
elseif ($num == 0) //login name not found
{
unset($_GET['do']);
$message = "The Login Name you entered does not
exist! Please try again.<br>";
include("login_form.inc");
}
break;
default:
include("login_form.inc");
}
?>