Ex1t Posted September 24, 2015 Share Posted September 24, 2015 (edited) Im using this query for login in standard PHP. $sql = 'SELECT * FROM admin WHERE username = "$username" AND password = "$password"'; $run_query = mysqli_query($con, $sql); $check_query = mysqli_num_rows($run_query); if(!$check_query) { echo 'Failed'; } else { echo 'Success'; } How should look that query in OOP?Im just started with OOP, I successfully created a connection with database in PDO, so now I have problem with this login queryIm just missed category, sorry moderators, please move.. Edited September 24, 2015 by Ex1t Quote Link to comment Share on other sites More sharing options...
benanamen Posted September 24, 2015 Share Posted September 24, 2015 (edited) It would look something like the following: * There are many PDO tutorials available. Google is your friend. try { $sql = "SELECT * FROM admin WHERE username=? and password=?"; $stmt = $pdo->prepare($sql); $stmt->execute(array( $username, $password )); } catch (PDOException $e) { // Handle error here. } Edited September 24, 2015 by benanamen Quote Link to comment Share on other sites More sharing options...
requinix Posted September 24, 2015 Share Posted September 24, 2015 Im just missed category, sorry moderators, please move..I think it's fine: PDO is about databases and this is a database forum. In here or in Coding Help would probably be alright either way. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.