lookinfreshuk
-
Posts
3 -
Joined
-
Last visited
Never
Posts posted by lookinfreshuk
-
-
NEW CODE AS YOU PUT ^^
<?PHP $usernames = array('admin','harts'); $passwords = array('admin','harts'); $page = array('index.php','Harts.php'); // Count the amount of users in array. $count_users = count ($usernames); // Set users found to "0" $user_found = '0'; // Set username and password variables from $_POST data. $username = $_POST['username']; $password = $_POST['password']; // Check to see if we gave a match in usernames // If we have a match set a cariable with the record number // Update "$user_found" if we find a match for($u=0; $u<$count_users; $u++) { if($username == $usernames[$u]) { $userRecord = $u; $user_found = '1'; } } // If no user is found, login has failed. Re-direct back to login. if(!$user_found) { header('Location: login.php?value=fail'); exit; } // If usernames don't match, login has failed. Re-direct back to login. if($usernames[$userRecord] !=$username) { header('Location: login.php?value=fail'); exit; // If passwords don't match, login has faled. Re-direct back to login. } else if($passwords[$userRecord] !=$password) { header('Location: login.php?vale=fail'); exit; // If usernames and passwords match, login succeeded. Re-direct to player specific page. } else { $_SESSION['username'] = $username; header("Location: $page[$userRecord]"); exit; } ?>
wont even allow the login, it wont move page, just says login failed... :S
thanks for the try tho!
-
hello,
i want to create a client login system so when they use there login it redirects them to a page only for them, is this possible? i am using the following code but it only re-drirects them after login to the "index.php" page not the 2nd user to "Harts.php", what am i doing wrong?, thanks
<?php
$usernames = array("admin","admin2");
$passwords = array("admin","admin2");
$page = array("index.php","Harts.php");
for($i=0;$i<count($usernames);$i++)
{
$logindata[$usernames[$i]]=$passwords[$i];
}
$found = 0;
for($i=0;$i<count($usernames);$i++)
{
if ($usernames[$i] == $_POST["username"])
{
$found = 1;
}
}
if ($found == 0)
{
header('Location: login.php?value=fail');
exit;
}
if($logindata[$_POST["username"]]==$_POST["password"])
{
session_start();
$_SESSION["username"]=$_POST["username"];
header('Location: '.$page);
exit;
}
else
{
header('Location: login.php?value=fail');
exit;
}
?>
Help with client login
in PHP Coding Help
Posted
anyone else got any ideas?