Jump to content

Recommended Posts

<?php

@ini_set('display_errors', 1);
@error_reporting(1);
@ini_set('allow_url_include', Off);
@set_time_limit(0);

require 'connect.php';

if($_SERVER['REQUEST_METHOD'] == "POST")
{
    
    $username = $_POST['username'];
    $password = $_POST['password'];
    
    $username = htmlspecialchars($username);
    $username = htmlentities($username);
    $username = strip_tags($username);
    
    if(preg_match("#[^\w]#", $username))
    {
     
        die("Your username must be numbers or letters only!");
        
    }
    
    $hash = hash('ripemd320', $password);
    
    if(empty($username) || empty($password))
    {
     
        die("Please enter both your username and password!");
        
    }
    
    $sql = "SELECT username, password FROM users WHERE BINARY username = :username AND BINARY password = :password";
    
    $stmt = $handler->prepare($sql);
    
    $stmt->bind_param("ss", $username, $hash);
    $stmt->execute();
    
    if($stmt->rowCount())
    {
     
        if($row['rank'] == 1)
        {
         
            $_SESSION['loggedIn'] = 1;
            $_SESSION['username'] = $username;
            $_SESSION['rank'] = $row['rank'];
            
            echo '<meta http-equiv="refresh" content="0;admin.php">';
            
        }
        
            $_SESSION['loggedIn'] = 1;
            $_SESSION['username'] = $username;
            $_SESSION['rank'] = $row['rank'];
            
            echo '<meta http-equiv="refresh" content="0;user.php">';
        
    }
    
}

?>

I'm getting the following error Call to undefined method PDOStatement::bind_param()

you are using the PDO statements for your database connection. all of the rest of your database statements must also be PDO statements.

 

the bind_parm() statement you are using is a mysqli statement. you cannot mix the different types of database statements.

 

i recommend that you use the php.net documentation as a reference source to avoid confusion like this.

ok thanks, and this is my connection script

<?php

try {
 
    $handler = new PDO("mysql:host=localhost;dbname=test;", "root", "");
    $handler->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    
} catch (PDOException $e) {
    
 
    echo "A connection could not be established to ".$_SERVER['SERVER_ADDR']." The following error has occurred: ".$e->getMessage()." ";
    
}

?>

no one stated there was a problem with your database connection, so i don't know why you posted the above code.

 

the problem is that there is no pdo bind_param() method. to use the PDO database statements correctly, you must read the php.net documentation for what you are doing. just coping things you have have seen someplace, without knowing what they mean and what they do, isn't going to work.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.