Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $host = 'localhost';
- $dbname = 'idolisetcg';
- $user = 'root';
- $password = '';
- $connect = new PDO("mysql:host=$host;dbname=$dbname", $user, $password);
- include("database_connection.php");
- if(isset($_POST["login"]))
- {
- if(empty($_POST["email"]) || empty($_POST["password"]))
- {
- $message = "<div class='alert alert-danger'>Both Fields are required</div>";
- }
- else
- {
- $query = "
- SELECT * FROM members
- WHERE email = :email
- ";
- $statement = $connect->prepare($query);
- $statement->execute(
- array(
- 'email' => $_POST["email"]
- )
- );
- $count = $statement->rowCount();
- if($count > 0)
- {
- $result = $statement->fetchAll();
- foreach($result as $row)
- {
- if(password_verify($_POST["password"], $row["password"]))
- {
- header("location:index.php");
- }
- else
- {
- $message = '<div class="alert alert-danger">Wrong Password</div>';
- }
- }
- }
- else
- {
- $message = "<div class='alert alert-danger'>Wrong Email Address</div>";
- }
- }
- }
- $result = $statement->fetchAll();
- foreach($result as $row)
- {
- if(password_verify($_POST["password"], $row["password"]))
- { if(password_needs_rehash($row["password"], PASSWORD_DEFAULT)){
- $newhash = password_hash($_POST["password"], PASSWORD_DEFAULT);
- }
- header("location:index.php");
- }
- $result = $statement->fetchAll();
- foreach($result as $row)
- {
- if(password_verify($_POST["password"], $row["password"]))
- { if(password_needs_rehash($row["password"], PASSWORD_DEFAULT) && md5($_POST["password"] === $row["password"]){
- $newhash = password_hash($_POST["password"], PASSWORD_DEFAULT);
- }
- header("location:index.php");
- }
Add Comment
Please, Sign In to add comment