Skip to content
  • P
    Projects
  • G
    Groups
  • S
    Snippets
  • Help

ahjoyo / idc0007

  • This project
    • Loading...
  • Sign in
Go to a project
  • Project
  • Repository
  • Issues 0
  • Merge Requests 0
  • Pipelines
  • Wiki
  • Snippets
  • Members
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Files
  • Commits
  • Branches
  • Tags
  • Contributors
  • Graph
  • Compare
  • Charts
Switch branch/tag
  • icd007
  • php
  • index.php
Find file
BlameHistoryPermalink
  • mhasan's avatar
    changes to index and view pages · 062b200e
    mhasan committed 6 years ago
    062b200e
index.php 825 Bytes
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
<?php
require "db_conn.php";
$e = null;

if (isset($_POST['submit'])) {
    try {

        $querry = sprintf("SELECT passHash FROM login WHERE userName = '%s' ;", $_POST['userName']);
        $pdo_st = $pdo->query($querry);
        $pdo_st->setFetchMode(PDO::FETCH_ASSOC);

        $array = $pdo_st->fetch();
        $isMatch = password_verify($_POST['pass'], $array['passHash']);

        if ($isMatch == true) {
            session_start();
            $_SESSION['userName'] = $_POST['userName'];
            header("location: ../view.php"); //redirects user to view page upon successful login!
        }
        else {
            header("location: ../index.php"); //redirects to the index page upon login failure.
        }
    } catch (PDOException $e) {
        echo ($e->getMessage() . " " . $e->getLine());
    }
}
?>