PHP Classes

File: fwphp/glomodul/z_examples/book_video/gallery_powers/authenticate.php

Recommend this page to a friend!
  Classes of Slavko Srakocic  >  B12 PHP FW  >  fwphp/glomodul/z_examples/book_video/gallery_powers/authenticate.php  >  Download  
File: fwphp/glomodul/z_examples/book_video/gallery_powers/authenticate.php
Role: Example script
Content type: text/plain
Description: Example script
Class: B12 PHP FW
Manage database records with a PDO CRUD interface
Author: By
Last change:
Date: 3 months ago
Size: 749 bytes


Class file image Download
require_once 'connection.php';
$conn = dbConnect('read', 'pdo');
// get the username's hashed password from the database
$sql = 'SELECT pwd FROM users WHERE username = ?';
// prepare statement
$stmt = $conn->prepare($sql);
// pass the input parameter as a single-element array
$storedPwd = $stmt->fetchColumn();
// check the submitted password against the stored version
if (password_verify($password, $storedPwd)) {
$_SESSION['authenticated'] = 'Jethro Tull';
// get the time the session started
$_SESSION['start'] = time();
header("Location: $redirect");
} else {
// if not verified, prepare error message
$error = 'Invalid username or password';

For more information send a message to info at phpclasses dot org.