3
Contributors
9
Replies
33
Views
3 Years
Discussion Span
Last Post by mohan@nano
0
<?php
include 'connectMySql.php';


session_start();
if(isset($_POST['login']))
{
    $username = mysql_real_escape_string($_POST['username']);
    $password = mysql_real_escape_string($_POST['password']);
    if($username && $password)
    {

        $query = mysql_query("SELECT * FROM users  WHERE username = '$username'");
        while($row=mysql_fetch_assoc($query))
        {
            $username = $row['username'];
            $password = $row['password'];
        }
        if($username==$username && $password==$password)
        {
            $_SESSION['username'] = $username;
            $_SESSION['password'] = $assword;
            header("location:members.php");
        }
        else
        {
            header("location:index.php?notify=Incorrect Username or Password.");
        }
    }
    else
    {
        header("location:index.php?notify=All fields are required.");
    }
}

?>
0

Try this

<?php
include 'connectMySql.php';

session_start();
if(isset($_POST['login']))
{
    $username = mysql_real_escape_string($_POST['username']);
    $password = mysql_real_escape_string($_POST['password']);
    if($username && $password)
    {
        $query = "SELECT * FROM users  WHERE username = '$username' AND password = '$password'";
        $result=mysql_query($query);
        $count=mysql_num_rows($result);

        if($count>0)
        {
            $_SESSION['username'] = $username;
            $_SESSION['password'] = $password;
            header("location:members.php");
        }
        else
        {
            header("location:index.php?notify=Incorrect Username or Password.");
        }
    }
    else
    {
        header("location:index.php?notify=All fields are required.");
    }
}

?>

Edited by Bachu: text correction

0
   <?php
    include 'connectMySql.php';
    session_start();
    if(isset($_POST['login']))
    {
    $username = mysql_real_escape_string($_POST['username']);
    $password = mysql_real_escape_string($_POST['password']);
    if($username && $password)
    {
    $query = mysql_query("SELECT * FROM users WHERE username = '$username' AND password='$password'");
    while($row=mysql_fetch_assoc($query))
    {
    $username = $row['username'];
    $password = $row['password'];
    }
    if($username==$username && $password==$password)
    {
    $_SESSION['username'] = $username;
    $_SESSION['password'] = $password;
    header("location:members.php");
    }
    else
    {
    header("location:index.php?notify=Incorrect Username or Password.");
    }
    }
    else
    {
    header("location:index.php?notify=All fields are required.");
    }
    }
    ?>

Edited by mohan@nano: wrongly typed

0

have you tried with already registerd users ... if u do like that means .. what error u should get ..

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.