/    Sign up×
Community /Pin to ProfileBookmark

PHP login with PDO connection

Hello.
I search to make a login interphase in PHP with PDO.
Can you help me ?

`<?php
include “database/db_connect.php”;
try {

$stmt = $conn->prepare(“SELECT * FROM login WHERE email=:email AND password=:password”);
$stmt->bindParam(‘:email’, $email);
$stmt->bindParam(‘:password’, $password);

$email = $_POST[“email”];
$salt = “asdf”;
$password = $_POST[“password”].$salt;
$password = sha1($password);
$stmt->execute();

if($stmt->rowCount()==1){
$results_login=$stmt->fetch(PDO::FETCH_ASSOC);
$_SESSION[’email’] = $results_login[’email’];
$_SESSION[‘password’] = $results_login[‘password’];
return true;
}else{
return false;
}

echo “Login successfully”;
}
catch(PDOException $e)
{
echo “Error: ” . $e->getMessage();
}
$conn = null;
?>`

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @Kelijsto spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...