Forum Moderators: coopster
The problem I am having is when i click the submit button the script doesnt go to header(location) it just refreshes the login prompt page.
The code is below
<?php
session_start();?
include '/home/www/juttuffi/header.php';
include '/home/www/juttuffi/dbc.php'; // db connector
>
<form action="<?php $SERVER['PHP_SELF'];?>" method="post">
<input type="text" name="user"/><br>
<input type="password" name="pass"/><br>
<input type="submit" value="login"/>
</form?
<?php
if(isset($_POST['username']) && $_POST['password']){
[code]
$username = $_POST['user'];
$password = $_POST['pass'];
$query = "SELECT * tadministrators WHERE uname = '$user' AND pwd = '$pass' ";
$result = mysql_query($query) or die("Unable to verify user because : " . mysql_error());
if(mysql_num_rows($result) == 1)
{
while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$_SESSION['usrname'] = $row['uname'];
}
$_SESSION['Authenticated'] = true;
header('Location: http://mydomain.com/control/index.php');
}
else
{
$err = "ERROR: Incorrect Username and/or Password";
}
echo '<span class="notice">';
echo $err;
echo '</span>';
echo '<br>';
echo ($result);
}
?>
Can anyone tell me where this code is going wrong? and why it isnt redirecting to /control/index.php and it is just refeshing the login.php which is the page the above code belongs too.
I would really appreciate it.
under your includes, there seem to be an error in closing the php tags
also the orm tag is not clossing correctly
(perhaps a copy/paste error?)
If these are indeed errors, then the header() will not work.
Also the header() must be places on top of the page, before any output. Where you have it it will just failed (under the <form>...</form>
[edited by: omoutop at 1:39 pm (utc) on Jan. 31, 2007]