Results 1 to 4 of 4

Thread: log in problem

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2007
    Posts
    39

    log in problem

    Hi
    could anyone please help me to sort out this proble, when I try to execute
    the error query not excuted, i know that the proble is the sekect command
    but no clue what is it!!


    PHP Code:
    <?php // script to check if the user stored in the MySQL database previously 

    session_start();

    include 
    "conn.inc.php";
    if(isset(
    $_POST['submit']))
    {
        
    $query "select username, password from user" 
        
        
    "where username = '" $_POST['username'] . "' " "ADN  password = (PASSWORD('" $_POST['password'] . " '))";
        
    // excute the query
        
    $result mysql_query($query)
        
        or die(
    "query not excuted!");
        
        if(
    mysql_num_rows($result) == 1)
        {
            
    $_SESSION['user_logged'] = $_SESSION['username'];
            
    $_SESSION['user_password'] = $_SESSION['password'];
            
            
    header("Refresh: 5; URL=" $_POST['redirect'] . "");
            echo 
    " you being redirected to your original page reques<br>";
            
            echo 
    "(if your browser not support this, " .
            
    "<a href =\"" $_POST['redirect'] . "\"> Click here</a>)";
            
        }
        else
        {
            
    ?>
            <html>
            <head><title> user_login</title></head>
            <body>
            
            <p>
            
            invalid and /or password<br>
            
            Not registered?
            
            <a href="register.php">Click here</a> to register.<br>
            
            <form action="user_login.php" method="POST">
            
            <input type="hidden" name="redirect" value="<?php echo  $_POST ['redirect']; ?>">
            
            Username : <input type="text" name="username"><br>

            Password : <input type="password" name="password"><br><br>
            
            <input type="submit" name="submit" value="Login">
            
            </form>
            
            </p>
            
            </body>
            </html>
            
            <?php
            
        
    }
        
    }
    else 
    {

        if(isset(
    $_GET['redirect']))
        {
            
    $redirect $_GET['redirect'];
            
        }else 
        {
            
    $redirect ="index1.php";
        }
        
    ?>
        <html>
        
        <head><title>Management system </title></head>
        
        <body>
        
        <p>
        
        login below by supplying your username/password..<br>
        
        or<a href="register.php"> Click here</a> to register.<br><br>
        
        <form action="user_login.php" method="POST">
            
        <input type="hidden" name="redirect" value="<?php echo $redirect?>">
            
        Username : <input type="text" name="username"><br>

        Password : <input type="password" name="password"><br><br>
            
        <input type="submit" name="submit" value="Login">
            
        </form>
        
        </p>
        </body>
        
        </html>
        <?php
    }
    ?>

  2. #2
    Frenzied Member Jmacp's Avatar
    Join Date
    Jul 2003
    Location
    UK
    Posts
    1,959

    Re: log in problem

    PHP Code:
    $query "select username, password from user" .  
         
        
    "where username = '" $_POST['username'] . "' " "ADN  password = (PASSWORD('" $_POST['password' 
    you need a space after user, so,

    PHP Code:
    $query "select username, password from user" .  
         
        
    " where username = '" $_POST['username'] . "' " "ADN  password = (PASSWORD('" $_POST['password' 
    otherwise your executing,

    PHP Code:
    select usernamepassword from userwhere usernameetc... 
    instead of,

    PHP Code:
    select usernamepassword from user where usernameetc... 

  3. #3
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: log in problem

    would you please quit making new threads over and over again? you must have made 10 topics in the past week about the same questions, over and over. reply to your old topic, don't make a new one.

    now, if you just look through your own code you cna figure out these problems for yourself. you spelled "AND" wrong (and put ADN), and you have a space before you close the call for "PASSWORD()", which means that you're appending a space to everyone's password (making them incorrect, basically). change to:
    PHP Code:
        $query "select username, password from user " 
        
        
    "where username = '" $_POST['username'] . "' AND  password = (PASSWORD('" $_POST['password'] . "'))"

  4. #4
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: log in problem

    Quote Originally Posted by omarali
    Hi
    could anyone please help me to sort out this proble, when I try to execute
    the error query not excuted, i know that the proble is the sekect command
    but no clue what is it!!


    PHP Code:
    <?php // script to check if the user stored in the MySQL database previously 

    session_start();

    include 
    "conn.inc.php";
    if(isset(
    $_POST['submit']))
    {
        
    $query "select username, password from user" 
        
        
    "where username = '" $_POST['username'] . "' " "ADN  password = (PASSWORD('" $_POST['password'] . " '))";
        
    // excute the query
        
    $result mysql_query($query)
        
        or die(
    "query not excuted!");
        
        if(
    mysql_num_rows($result) == 1)
        {
            
    $_SESSION['user_logged'] = $_SESSION['username'];
            
    $_SESSION['user_password'] = $_SESSION['password'];
            
            
    header("Refresh: 5; URL=" $_POST['redirect'] . "");
            echo 
    " you being redirected to your original page reques<br>";
            
            echo 
    "(if your browser not support this, " .
            
    "<a href =\"" $_POST['redirect'] . "\"> Click here</a>)";
            
        }
        else
        {
            
    ?>
            <html>
            <head><title> user_login</title></head>
            <body>
            
            <p>
            
            invalid and /or password<br>
            
            Not registered?
            
            <a href="register.php">Click here</a> to register.<br>
            
            <form action="user_login.php" method="POST">
            
            <input type="hidden" name="redirect" value="<?php echo  $_POST ['redirect']; ?>">
            
            Username : <input type="text" name="username"><br>

            Password : <input type="password" name="password"><br><br>
            
            <input type="submit" name="submit" value="Login">
            
            </form>
            
            </p>
            
            </body>
            </html>
            
            <?php
            
        
    }
        
    }
    else 
    {

        if(isset(
    $_GET['redirect']))
        {
            
    $redirect $_GET['redirect'];
            
        }else 
        {
            
    $redirect ="index1.php";
        }
        
    ?>
        <html>
        
        <head><title>Management system </title></head>
        
        <body>
        
        <p>
        
        login below by supplying your username/password..<br>
        
        or<a href="register.php"> Click here</a> to register.<br><br>
        
        <form action="user_login.php" method="POST">
            
        <input type="hidden" name="redirect" value="<?php echo $redirect?>">
            
        Username : <input type="text" name="username"><br>

        Password : <input type="password" name="password"><br><br>
            
        <input type="submit" name="submit" value="Login">
            
        </form>
        
        </p>
        </body>
        
        </html>
        <?php
    }
    ?>
    If you use mysql error, you might be able to find out what your error is all by yourself
    PHP Code:
    echo(mysql_error()); 
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width