I made the following code by trying the page array you gave me.
<?php
$db=mysql_connect("localhost","root") or die ("cant connect");
mysql_select_db("Users",$db) or die ("cant change");
$result=mysql_query("select * from user where username='".$_POST['username']."'", $db) or die ("cant do it");
$row=mysql_fetch_array($result);
if ($row["password"] == $_POST['password']) {
$pages = array
("jaims" => "jaims.php",
"test" => "page1.php",
"user3" => "page3.php",
"user4" => "page4.php",
"user5" => "page5.php");
$redirectPage = $pages["$username"];
header("Location: $redirectPage");
}
?>
I got this as error:
Warning: Cannot add header information - headers already sent by (output started at f:\program files\easyphp\www\successlog.php:3) in f:\program files\easyphp\www\successlog.php on line 21
I made another one by redirecting the user directly to his corresponding page by adding a column page in my mysql, as you said.
$db=mysql_connect("localhost","root") or die ("cant connect");
mysql_select_db("Users",$db) or die ("cant change");
$result=mysql_query("select * from user where username='".$_POST['username']."'", $db) or die ("cant do it");
$row=mysql_fetch_array($result);
if ($row["password"] == $_POST['password']) {
?>
<html>
<head>
<meta http-equiv="refresh" content="0;URL=<?$row["page"]?>.php">
</head>
<body>
</body>
</html>
<?
}
//
?>
This second code seems to make an unending request but would not load the page of the corresponding user. When I change the url into a normal page, it works (ex. download.htm).
I can feel that I'm not too far from the solution, I just need your expertise by identifying what's wrong with my code.
Thanks again