www.webdeveloper.com
Results 1 to 2 of 2

Thread: Log In Script problems

  1. #1
    Join Date
    Apr 2014
    Posts
    38

    Log In Script problems

    Hi Guys,

    I'm having a few issues, I have managed yo let users register this works fine. But When the registerd user tries to log into the site I'm getting the following error message

    Warning: mysqli_query() expects at least 2 parameters, 1 given in C:\xampp\htdocs\login.php on line 16

    Warning: mysqli_error() expects exactly 1 parameter, 0 given in C:\xampp\htdocs\login.php on line 16

    This is my code

    Code:
    <?php
    // checkLogin.php
    
    session_start(); // Start a new session
    require('config.php'); // Holds all of our database connection information
    // Get the data passed from the form
    $username = $_POST['username'];
    $password = $_POST['password'];
    
    // Do some basic sanitizing
    $username = stripslashes($username);
    $password = stripslashes($password);
    
    $sqli = "select * from 'users' where username = '$username' and password = '$password'";
    
    $result = mysqli_query($sqli) or die ( mysqli_error() );
    $count = 0;
    while ($line = mysqli_fetch_assoc($result)) {
    
         $count++;
    	 }
    if ($count == 1) {
    
         $_SESSION['loggedIn'] = "true";
    
         header("Location: loginSuccess.php"); // This is wherever you want to redirect the user to
    
    } else {
    
         $_SESSION['loggedIn'] = "false";
    
         header("Location: loginFailed.php"); // Wherever you want the user to go when they fail the login
    
    }
    
     ?>
    Any ideas? All help is much appreicated

    Rich

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,609
    Well, the error messages seem pretty clear (not providing enough parameters). Have you tried actually looking at the manual pages for those two functions to see what the paramenters are? (Or using OOP syntax so you don't have to keep supplying the MySQLi link resource parameter?)

    mysqli_query
    mysqli_error
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles