SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Sep 2010
    Posts
    131
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Recognizing data

    I am having trouble with the php statements in session.php to recognize the result of the correct $user and $pass.
    I have a MySQL table called "register" with usernames and passwords,

    session.php
    PHP Code:
    <?php
        $result
    ="";
        
    $user filter_input(INPUT_POST"user");
        
    $pass filter_input(INPUT_POST"pass");
        if (
    $user!=null And $pass!=null){
            
    $conn mysql_connect(connectionstring works);
            
    mysql_select_db('db1');
            
    $sql "SELECT * FROM register WHERE username=$user And password=$pass;";
            
    $result mysql_query($sql$conn);
        }
        if (
    $result==null) {
            return 
    header("Location: http://www.philosophaie.com/htmlphp/secure_login.htm");
        }
    ?>

  2. #2
    SitePoint Addict bronze trophy
    Join Date
    Sep 2005
    Posts
    318
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    You could try using mysql_num_rows();

    Code:
    if(mysql_num_rows($result) == 0) {
    echo"bad login";
    }

  3. #3
    SitePoint Zealot
    Join Date
    Sep 2010
    Posts
    131
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I changed $sql to this but it still did not work:

    Code:
    $sql = "SELECT * FROM register WHERE username=" & $user & " And password=" & $pass & ";";


Bookmarks

Posting Permissions

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