Peuplarchie
07-27-2008, 08:11 AM
Good day to you all,
I'm working on my login script and I was wondering how can i make the txt file based login to look into 3 txt file for login and password ?
My problem is I don't have a clue on how to code it.
Here is my code :
<table border="1" cellpadding="0" cellspacing="0" align="center" width="800" align="top">
<tr><td width="800" class="black" valign="top" align="right">
<?php
session_start();
$file = file("pass.txt");
$data= array();
foreach($file as $value){
list($user, $password, $url) = explode('=>', $value);
$data[$user] = array("url"=>$url, "password"=>$password);
}
if(isset($_POST['username']) && isset($_POST['password'])) {
if($data[$_POST['username']]['password'] == $_POST['password']) {
$_SESSION['username'] = $_POST['username'] . " " . $_POST['password'];
$_SESSION['users'] = $_POST['username'];
$_SESSION['present'] = true;
header('Location: ' . $data[$_POST['username']]['url']);
} else {
login('Wrong user name or password. <br>');
}
} else {
login();
}
?><?php
function login($response='Admin login') {
?>
<p><?=$response?></p>
<form action="" method="post">
<b>User name</b>
<input name="username" type="text" />
<b>Code</b>
<input name="password" type="password">
<input type="submit" value="Login" />
</form>
<?php } ?>
</td></tr>
</table>
Thank for any help !
I'm working on my login script and I was wondering how can i make the txt file based login to look into 3 txt file for login and password ?
My problem is I don't have a clue on how to code it.
Here is my code :
<table border="1" cellpadding="0" cellspacing="0" align="center" width="800" align="top">
<tr><td width="800" class="black" valign="top" align="right">
<?php
session_start();
$file = file("pass.txt");
$data= array();
foreach($file as $value){
list($user, $password, $url) = explode('=>', $value);
$data[$user] = array("url"=>$url, "password"=>$password);
}
if(isset($_POST['username']) && isset($_POST['password'])) {
if($data[$_POST['username']]['password'] == $_POST['password']) {
$_SESSION['username'] = $_POST['username'] . " " . $_POST['password'];
$_SESSION['users'] = $_POST['username'];
$_SESSION['present'] = true;
header('Location: ' . $data[$_POST['username']]['url']);
} else {
login('Wrong user name or password. <br>');
}
} else {
login();
}
?><?php
function login($response='Admin login') {
?>
<p><?=$response?></p>
<form action="" method="post">
<b>User name</b>
<input name="username" type="text" />
<b>Code</b>
<input name="password" type="password">
<input type="submit" value="Login" />
</form>
<?php } ?>
</td></tr>
</table>
Thank for any help !