The coding which is i used i get from a website people appriciate this script so i get that one but the login script doesn't work i have a table
called userid,username,password
and the inserted values is userid 1 ,username admin,password waridtel but some thing went wrong the script is here see and tell me
PHP Code:
<?php
include('vars.php');
include('connection.php');
//check that the user is calling the page from the login form and not accessing it directly
//and redirect back to the login form if necessary
if (!isset($username) || !isset($password)) {
echo "<script type='text/javascript'>";
echo "window.location = 'index.php'";
echo "</script>";
}
//check that the form fields are not empty, and redirect back to the login page if they are
elseif (empty($username) || empty($password)) {
echo "<script type='text/javascript'>";
echo "window.location = 'index.php' ";
echo "</script>";
}
else{
//convert the field values to simple variables
//add slashes to the username and md5() the password
$user = addslashes($_POST['username']);
$pass = md5($_POST['password']);
$result=mysql_query("select * from user where username='$user' AND password='$pass'");
//check that at least one row was returned
//$rowCheck = mysql_num_rows($result);
//if($rowCheck = 1 ){
while($row = mysql_fetch_assoc($result)){
//start the session and register a variable
session_start();
session_register('username');
//successful login code will go here...
echo 'Success!';
//we will redirect the user to another page where we will make sure they're logged in
echo "<script type='text/javascript'>";
echo "window.location = 'index2.php' ";
echo "</script>";
}
/* }
else {
//if nothing is returned by the query, unsuccessful login code goes here...
echo 'Incorrect login name or password. Please try again.';
} */
}
?>