Home › Forums › Back End › Try out my first PHP web app! › Reply To: Try out my first PHP web app!
August 4, 2014 at 1:23 pm
#177593
__
Participant
How do I pull data from the database without a loop?
Depends on what api you are using. For example, with PDO:
$DB = new PDO(
'mysql:host=localhost;dbname=your_db;charset=UTF8',
'mysql username',
'mysql password'
);
$DB_getHash = $DB->prepare( 'select hash from users where username=?' );
$DB_getHash->execute( array( $_POST['username'] ) );
$queryResult = $DB_getHash->fetch();
if(
$queryResult
&& password_verify( $_POST['password'],$queryResult['hash'] )
){
// login successful
}
else{
// login failed
}