I am having a problem with being rejected the first time. I have
login.htm:
auth.php:
usrupload.php:
When I login I get my rejection page the first time. I go back and it allows me to login. It happens every time this way.
auth.php:
<?php
@$name = $_POST ['usrname'];
@$pass = $_POST ['pword'];
//Assumes the login is false
$auth=false;
// Checks for a login name and passwword
if(isset($name) && isset($pass)) {
//Opens pasword file and reads contents
$filename = '/path/to/file/auth.txt';
$fp=fopen($filename,"r");
$file_contents=fread($fp, filesize($filename));
fclose($fp);
//Sorts file contents for use
$lines = explode("\n", $file_contents);
foreach ($lines as $line) {
list($usrname,$pword)= explode(':',$line);
//Checks for a match
if(($usrname == $name) && ($pword == $pass)) {
//Sets login to true
$auth=true;
break;
}
}
}
if(!$auth){
//Rejection notice and redirect
include ('reject.php');
exit();
}else{
//Starts a session var
session_start();
session_register("SESSION");
session_register("SESSION_UNAME");
$SESSION_UNAME = $usrname;
//Location for uploading
header ("Location: [url]http://mysite.com/usrupload.php[/url]");
exit();
}
?>
usrupload.php:
<?php
//Checks for session
session_start();
@$usrname = $_SESSION['SESSION_UNAME'];
if(!session_is_registered("SESSION"))
//Redirect for a login
include ('reject.php');
//Includes uploading file if a session was availiable
else (include "$usrname.php");
exit();
?>
Thanks in advance,
Wil