strange authentication problem
Posted: Mon Jul 07, 2003 5:09 pm
hello,
I've written a user authentication script and i see it working quite strange.when i point to this location, http://localhost/project/index.php and enter the user name and password it does'nt work.
And when i point to this location, http://localhost/project/template.php, it redirects to index.php and when i enter the user name and password, its working
Please help me out with this one.
thank you
Heres the code for index.php
I've written a user authentication script and i see it working quite strange.when i point to this location, http://localhost/project/index.php and enter the user name and password it does'nt work.
And when i point to this location, http://localhost/project/template.php, it redirects to index.php and when i enter the user name and password, its working
Please help me out with this one.
thank you
Heres the code for index.php
Code: Select all
<?php
session_start();
ob_start();
session_register(logged);
$_SESSION['logged'] = 0;
?>
<html>
<head>
<title>Account Management Tool</title>
</head>
<body>
<?php
$redirect = $_GET['redirect'];
if (isset($_POST['submit']))
{
if ($_POST['username'] == "admin" && $_POST['password'] == "phpbeginner")
{
$redirect = $_POST['redirect'];
$_SESSION['logged'] = 1;
header ("Location: $redirect");
}
else
{
?>
Invalid Username and/or Password<br><br>
<form action="index.php" method="post">
<input type="hidden" name="redirect" value="<? echo $redirect; ?>">
<table align="center" border="1" width="324" bgcolor="#CCCCCC" bordercolordark="black" bordercolorlight="black">
<tr>
<td width="314" height="37">
<p align="center"><span style="font-size:9pt;"><font face="Verdana">Please enter the user name and the password</font></span></p>
<p> <span style="font-size:11pt;"> </span><font face="Verdana"><span style="font-size:11pt;">User
name </span> </font> <input type="text" name="username"> </p>
<p> <span style="font-size:11pt;"><font face="Verdana">Password</font></span>
<input type="password" name="password"></p>
<p> <input type="submit" name="submit" value="Login" style="font-family:Verdana;"></p>
<p> </p>
</td>
</tr>
</table>
</form>
<?
}
}
else
{
?>
You must be logged in to view this page<br><br>
<form action="index.php" method="post">
<input type="hidden" name="redirect" value="<? echo $redirect; ?>">
<table align="center" border="1" width="324" bgcolor="#CCCCCC" bordercolordark="black" bordercolorlight="black">
<tr>
<td width="314" height="37">
<p align="center"><span style="font-size:9pt;"><font face="Verdana">Please enter the user name and the password</font></span></p>
<p> <span style="font-size:11pt;"> </span><font face="Verdana"><span style="font-size:11pt;">User
name </span> </font> <input type="text" name="username"> </p>
<p> <span style="font-size:11pt;"><font face="Verdana">Password</font></span>
<input type="password" name="password"></p>
<p> <input type="submit" name="submit" value="Login" style="font-family:Verdana;"></p>
<p> </p>
</td>
</tr>
</table>
</form>
<?
}
?>
</body>
</html>