config.php
<?php
$con = mysql_connect("localhost","root","");
if(!$con){
die('could not connect:'.mysql_error());
}
mysql_select_db("thesis",$con);
?>
.................................................. .................................................. ...........
LoginAdmin.php
<?php
$login_form = <<<EOD
<form name="login" id="login" method="GET" action="CheckLogin.php">
<p><label for="username">Please Enter Username: </label><input type="text" size="30" name="username" id="username" /></p>
<p><label for="password">Please Enter Password: </label><input type="password" size="30" name="password" id="password" /></p>
<p><input type="submit" name="submit" id="submit" value="Submit"/> <input type="Reset" name="reset" id="reset" value="reset"/></p>
</form>
EOD;
$msg = $_GET['msg']; //GET the message
if($msg!='') echo '<p>'.$msg.'</p>'; //If message is set echo it
echo $login_form;
?>
.................................................. .................................................. ...........
CheckLogin.php
// And i feel this is my problem !!!
<?php
include "config.php";
$username = strtolower($_POST["username"]);
$password = $_POST["password"];
if ($username !="" && $password !=""){
//select username and password from database
$sql="SELECT * FROM user_account WHERE username='$username' and password='$password'";
$query = mysql_query($sql);
$row = mysql_fetch_array($query);
$ctr = mysql_num_rows($query);
if($ctr > 0)
{
ob_start();
$_SESSION['username'];
$_SESSION['password'];
session_register("username");
session_register("password");
header("location:AdminCategory.php");
}
else
{
echo '<script language="javascript">alert(\'Account does not exists.\');window.location =\'LoginAdmin.php\';</script>';
}
ob_end_flush();
}
else{
echo '<script language="javascript">alert(\'invalid username or password.\');window.location =\'LoginAdmin.php\';</script>';
}
?>
please reply ! thanks in advance !!!