PDO Login
parent
3675109e6d
commit
120817a920
@ -0,0 +1 @@
|
||||
<?php include("view/footer.php"); ?>
|
@ -0,0 +1 @@
|
||||
<?php include("view/footer.php"); ?>
|
@ -0,0 +1 @@
|
||||
<?php include("view/footer.php"); ?>
|
@ -0,0 +1 @@
|
||||
<?php include("view/footer.php"); ?>
|
@ -1,3 +1,9 @@
|
||||
# BeerListOfMine
|
||||
|
||||
PHP web - Semestrální práce na předmět Vývoj a administrace databázových aplikací - [OPBI2I126B]
|
||||
# PHP web - Semestrální práce na předmět Vývoj a administrace databázových aplikací - [OPBI2I126B]
|
||||
|
||||
## TO DO:
|
||||
*Make searchbar work*
|
||||
*Add editors and extend the database*
|
||||
*Implement articles*
|
||||
*Implement listing and following*
|
||||
|
@ -0,0 +1,159 @@
|
||||
-- MySQL Script generated by MySQL Workbench
|
||||
-- Tue 08 Feb 2022 03:13:53 AM CET
|
||||
-- Model: New Model Version: 1.0
|
||||
-- MySQL Workbench Forward Engineering
|
||||
|
||||
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
|
||||
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
|
||||
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Schema vujovicig
|
||||
-- -----------------------------------------------------
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Schema vujovicig
|
||||
-- -----------------------------------------------------
|
||||
CREATE SCHEMA IF NOT EXISTS `vujovicig` ;
|
||||
USE `vujovicig` ;
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Table `vujovicig`.`user`
|
||||
-- -----------------------------------------------------
|
||||
DROP TABLE IF EXISTS `vujovicig`.`user` ;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `vujovicig`.`user` (
|
||||
`id` INT NOT NULL AUTO_INCREMENT,
|
||||
`nick` VARCHAR(25) NOT NULL,
|
||||
`mail` VARCHAR(255) NOT NULL,
|
||||
`password` VARCHAR(255) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE INDEX `nick_UNIQUE` (`nick` ASC))
|
||||
ENGINE = InnoDB;
|
||||
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Table `vujovicig`.`brewery`
|
||||
-- -----------------------------------------------------
|
||||
DROP TABLE IF EXISTS `vujovicig`.`brewery` ;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `vujovicig`.`brewery` (
|
||||
`id` INT NOT NULL AUTO_INCREMENT,
|
||||
`name` VARCHAR(45) NULL,
|
||||
`region` VARCHAR(45) NULL,
|
||||
`description` MEDIUMTEXT NULL,
|
||||
PRIMARY KEY (`id`))
|
||||
ENGINE = InnoDB;
|
||||
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Table `vujovicig`.`beer`
|
||||
-- -----------------------------------------------------
|
||||
DROP TABLE IF EXISTS `vujovicig`.`beer` ;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `vujovicig`.`beer` (
|
||||
`id` INT NOT NULL AUTO_INCREMENT,
|
||||
`name` VARCHAR(45) NOT NULL,
|
||||
`alc` FLOAT NOT NULL,
|
||||
`ibu` INT NULL,
|
||||
`description` MEDIUMTEXT NULL,
|
||||
`brewery_id` INT NOT NULL,
|
||||
PRIMARY KEY (`id`, `brewery_id`),
|
||||
INDEX `fk_beer_brewery1_idx` (`brewery_id` ASC),
|
||||
CONSTRAINT `fk_beer_brewery1`
|
||||
FOREIGN KEY (`brewery_id`)
|
||||
REFERENCES `vujovicig`.`brewery` (`id`)
|
||||
ON DELETE NO ACTION
|
||||
ON UPDATE NO ACTION)
|
||||
ENGINE = InnoDB;
|
||||
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Table `vujovicig`.`tag`
|
||||
-- -----------------------------------------------------
|
||||
DROP TABLE IF EXISTS `vujovicig`.`tag` ;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `vujovicig`.`tag` (
|
||||
`id` INT NOT NULL AUTO_INCREMENT,
|
||||
`tag_title` VARCHAR(45) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE INDEX `tag_title_UNIQUE` (`tag_title` ASC))
|
||||
ENGINE = InnoDB;
|
||||
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Table `vujovicig`.`follow`
|
||||
-- -----------------------------------------------------
|
||||
DROP TABLE IF EXISTS `vujovicig`.`follow` ;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `vujovicig`.`follow` (
|
||||
`user_id` INT NOT NULL,
|
||||
`brewery_id` INT NOT NULL,
|
||||
PRIMARY KEY (`user_id`, `brewery_id`),
|
||||
INDEX `fk_user_has_brewery_brewery1_idx` (`brewery_id` ASC),
|
||||
INDEX `fk_user_has_brewery_user_idx` (`user_id` ASC),
|
||||
CONSTRAINT `fk_user_has_brewery_user`
|
||||
FOREIGN KEY (`user_id`)
|
||||
REFERENCES `vujovicig`.`user` (`id`)
|
||||
ON DELETE NO ACTION
|
||||
ON UPDATE NO ACTION,
|
||||
CONSTRAINT `fk_user_has_brewery_brewery1`
|
||||
FOREIGN KEY (`brewery_id`)
|
||||
REFERENCES `vujovicig`.`brewery` (`id`)
|
||||
ON DELETE NO ACTION
|
||||
ON UPDATE NO ACTION)
|
||||
ENGINE = InnoDB;
|
||||
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Table `vujovicig`.`list`
|
||||
-- -----------------------------------------------------
|
||||
DROP TABLE IF EXISTS `vujovicig`.`list` ;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `vujovicig`.`list` (
|
||||
`user_id` INT NOT NULL,
|
||||
`beer_id` INT NOT NULL,
|
||||
`rating` INT(5) NULL,
|
||||
PRIMARY KEY (`user_id`, `beer_id`),
|
||||
INDEX `fk_user_has_beer_beer1_idx` (`beer_id` ASC),
|
||||
INDEX `fk_user_has_beer_user1_idx` (`user_id` ASC),
|
||||
CONSTRAINT `fk_user_has_beer_user1`
|
||||
FOREIGN KEY (`user_id`)
|
||||
REFERENCES `vujovicig`.`user` (`id`)
|
||||
ON DELETE NO ACTION
|
||||
ON UPDATE NO ACTION,
|
||||
CONSTRAINT `fk_user_has_beer_beer1`
|
||||
FOREIGN KEY (`beer_id`)
|
||||
REFERENCES `vujovicig`.`beer` (`id`)
|
||||
ON DELETE NO ACTION
|
||||
ON UPDATE NO ACTION)
|
||||
ENGINE = InnoDB;
|
||||
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Table `vujovicig`.`beer_has_tag`
|
||||
-- -----------------------------------------------------
|
||||
DROP TABLE IF EXISTS `vujovicig`.`beer_has_tag` ;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `vujovicig`.`beer_has_tag` (
|
||||
`beer_id` INT NOT NULL,
|
||||
`tag_id` INT NOT NULL,
|
||||
PRIMARY KEY (`beer_id`, `tag_id`),
|
||||
INDEX `fk_beer_has_tag_tag1_idx` (`tag_id` ASC),
|
||||
INDEX `fk_beer_has_tag_beer1_idx` (`beer_id` ASC),
|
||||
CONSTRAINT `fk_beer_has_tag_beer1`
|
||||
FOREIGN KEY (`beer_id`)
|
||||
REFERENCES `vujovicig`.`beer` (`id`)
|
||||
ON DELETE NO ACTION
|
||||
ON UPDATE NO ACTION,
|
||||
CONSTRAINT `fk_beer_has_tag_tag1`
|
||||
FOREIGN KEY (`tag_id`)
|
||||
REFERENCES `vujovicig`.`tag` (`id`)
|
||||
ON DELETE NO ACTION
|
||||
ON UPDATE NO ACTION)
|
||||
ENGINE = InnoDB;
|
||||
|
||||
|
||||
SET SQL_MODE=@OLD_SQL_MODE;
|
||||
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
|
||||
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
|
@ -0,0 +1,59 @@
|
||||
-- User
|
||||
|
||||
use vujovicig;
|
||||
|
||||
insert into user ( nick, mail, password ) values ( 'snowflake', 'snowflake@cocain.ninja', '$2y$10$QVa2JNaw.VozkHyRWlEGNeAjYfiHEksxVVMhDZPjhGsuAY9MO51.C' );
|
||||
insert into user ( nick, mail, password ) values ( 'pepino', 'prochazka@pedf.cuni.cz', '$2y$10$QVa2JNaw.VozkHyRWlEGNeAjYfiHEksxVVMhDZPjhGsuAY9MO51.C' );
|
||||
insert into user ( nick, mail, password ) values ( 'test', 'test@mail.cz', '$2y$10$QVa2JNaw.VozkHyRWlEGNeAjYfiHEksxVVMhDZPjhGsuAY9MO51.C' );
|
||||
insert into user ( nick, mail, password ) values ( 'aaaaa', 'test@mail.cz', '$2y$10$QVa2JNaw.VozkHyRWlEGNeAjYfiHEksxVVMhDZPjhGsuAY9MO51.C' );
|
||||
insert into user ( nick, mail, password ) values ( 'aaaa', 'test@mail.cz', '$2y$10$QVa2JNaw.VozkHyRWlEGNeAjYfiHEksxVVMhDZPjhGsuAY9MO51.C' );
|
||||
insert into user ( nick, mail, password ) values ( 'aaa', 'test@mail.cz', '$2y$10$QVa2JNaw.VozkHyRWlEGNeAjYfiHEksxVVMhDZPjhGsuAY9MO51.C' );
|
||||
insert into user ( nick, mail, password ) values ( 'aa', 'test@mail.cz', '$2y$10$QVa2JNaw.VozkHyRWlEGNeAjYfiHEksxVVMhDZPjhGsuAY9MO51.C' );
|
||||
|
||||
|
||||
insert into brewery (name, region, description) values ( 'Zichovec', 'Louny', 'Remeslny pivovar');
|
||||
insert into brewery (name, region, description) values ( 'Siberia', 'Praha 9-Vysočany', 'Remeslny pivovar');
|
||||
insert into brewery (name, region, description) values ( 'Matuska', 'Broumy', 'Remeslny pivovar');
|
||||
insert into brewery (name, region, description) values ( 'Cestmir', 'Stara Boleslav', 'Remeslny pivovar');
|
||||
insert into brewery (name, region, description) values ( 'Prazdroj', 'Plzen', 'Pilsner Urquell');
|
||||
|
||||
insert into beer ( name, alc, ibu, description, brewery_id) values ( 'Robin', 5.1, '40', '12', '1' );
|
||||
insert into beer ( name, alc, ibu, description, brewery_id) values ( 'Krahulik', 5.0, '32', '12', '1' );
|
||||
insert into beer ( name, alc, ibu, description, brewery_id) values ( 'Pilsner Urquell', 4.4, '38', '12', '5' );
|
||||
insert into beer ( name, alc, ibu, description, brewery_id) values ( 'Zlata Raketa', 7.0, '60', '17', '3' );
|
||||
insert into beer ( name, alc, ibu, description, brewery_id) values ( 'Yummy Blackcurrant Raspberry & Lingonberry', 5.1, '40', '12', '2' );
|
||||
|
||||
insert into tag ( tag_title ) values ( 'IPA' );
|
||||
insert into tag ( tag_title ) values ( 'APA' );
|
||||
insert into tag ( tag_title ) values ( 'LEZAK' );
|
||||
insert into tag ( tag_title ) values ( 'PASTRY SOUR' );
|
||||
insert into tag ( tag_title ) values ( 'SOUR' );
|
||||
insert into tag ( tag_title ) values ( 'NEIPA' );
|
||||
|
||||
insert into beer_has_tag ( beer_id, tag_id ) values ( '4', '1' );
|
||||
insert into beer_has_tag ( beer_id, tag_id ) values ( '1', '2' );
|
||||
insert into beer_has_tag ( beer_id, tag_id ) values ( '2', '3' );
|
||||
insert into beer_has_tag ( beer_id, tag_id ) values ( '3', '3' );
|
||||
insert into beer_has_tag ( beer_id, tag_id ) values ( '5', '4' );
|
||||
insert into beer_has_tag ( beer_id, tag_id ) values ( '5', '5' );
|
||||
|
||||
insert into follow ( user_id, brewery_id ) values ( '1', '1' );
|
||||
insert into follow ( user_id, brewery_id ) values ( '1', '2' );
|
||||
insert into follow ( user_id, brewery_id ) values ( '1', '3' );
|
||||
insert into follow ( user_id, brewery_id ) values ( '1', '4' );
|
||||
insert into follow ( user_id, brewery_id ) values ( '1', '5' );
|
||||
insert into follow ( user_id, brewery_id ) values ( '2', '5' );
|
||||
insert into follow ( user_id, brewery_id ) values ( '2', '3' );
|
||||
insert into follow ( user_id, brewery_id ) values ( '3', '1' );
|
||||
insert into follow ( user_id, brewery_id ) values ( '3', '2' );
|
||||
|
||||
insert into list ( user_id, beer_id, rating ) values ( '1', '1', '5' );
|
||||
insert into list ( user_id, beer_id, rating ) values ( '1', '2', '4' );
|
||||
insert into list ( user_id, beer_id, rating ) values ( '1', '3', '5' );
|
||||
insert into list ( user_id, beer_id, rating ) values ( '1', '4', '4' );
|
||||
insert into list ( user_id, beer_id, rating ) values ( '1', '5', '5' );
|
||||
insert into list ( user_id, beer_id, rating ) values ( '2', '3', '5' );
|
||||
insert into list ( user_id, beer_id ) values ( '2', '4');
|
||||
insert into list ( user_id, beer_id ) values ( '2', '1' );
|
||||
insert into list ( user_id, beer_id, rating ) values ( '3', '4', '5' );
|
||||
insert into list ( user_id, beer_id, rating ) values ( '3', '5', '5');
|
Binary file not shown.
Binary file not shown.
@ -1,7 +1,10 @@
|
||||
<?php require("view/header.php"); ?>
|
||||
<?php
|
||||
session_start();
|
||||
|
||||
<?php require("view/mainContent.php"); ?>
|
||||
require("view/header.php");
|
||||
|
||||
<?php require("view/sidebar.php"); ?>
|
||||
require("view/mainContent.php");
|
||||
|
||||
<?php include("view/footer.php"); ?>
|
||||
require("view/sidebar.php");
|
||||
|
||||
include("view/footer.php");
|
||||
|
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
// Initialize the session
|
||||
session_start();
|
||||
|
||||
// Unset all of the session variables
|
||||
$_SESSION = array();
|
||||
|
||||
// Destroy the session.
|
||||
session_destroy();
|
||||
|
||||
// Redirect to login page
|
||||
header("location: index.php");
|
||||
exit;
|
||||
?>
|
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
define("DB_SERVER", "localhost");
|
||||
define("DB_USER", "vujovicig");
|
||||
define("DB_PASS", "123Kappa123");
|
||||
define("DB_NAME", "vujovicig");
|
||||
|
||||
try{
|
||||
$pdo = new PDO("mysql:host=" . DB_SERVER . ";dbname=" . DB_NAME, DB_USER, DB_PASS);
|
||||
// Set the PDO error mode to exception
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
} catch(PDOException $e){
|
||||
die("ERROR: Could not connect. " . $e->getMessage());
|
||||
}
|
||||
?>
|
@ -0,0 +1,106 @@
|
||||
<?php
|
||||
// Initialize the session
|
||||
session_start();
|
||||
|
||||
// Check if the user is logged in, otherwise redirect to login page
|
||||
if(!isset($_SESSION["loggedin"]) || $_SESSION["loggedin"] !== true){
|
||||
header("location: index.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
// Include config file
|
||||
require_once "config.php";
|
||||
|
||||
// Define variables and initialize with empty values
|
||||
$new_password = $confirm_password = "";
|
||||
$new_password_err = $confirm_password_err = "";
|
||||
|
||||
// Processing form data when form is submitted
|
||||
if($_SERVER["REQUEST_METHOD"] == "POST"){
|
||||
|
||||
// Validate new password
|
||||
if(empty(trim($_POST["new_password"]))){
|
||||
$new_password_err = "Please enter the new password.";
|
||||
} elseif(strlen(trim($_POST["new_password"])) < 6){
|
||||
$new_password_err = "Password must have atleast 6 characters.";
|
||||
} else{
|
||||
$new_password = trim($_POST["new_password"]);
|
||||
}
|
||||
|
||||
// Validate confirm password
|
||||
if(empty(trim($_POST["confirm_password"]))){
|
||||
$confirm_password_err = "Please confirm the password.";
|
||||
} else{
|
||||
$confirm_password = trim($_POST["confirm_password"]);
|
||||
if(empty($new_password_err) && ($new_password != $confirm_password)){
|
||||
$confirm_password_err = "Password did not match.";
|
||||
}
|
||||
}
|
||||
|
||||
// Check input errors before updating the database
|
||||
if(empty($new_password_err) && empty($confirm_password_err)){
|
||||
// Prepare an update statement
|
||||
$sql = "UPDATE users SET password = ? WHERE id = ?";
|
||||
|
||||
if($stmt = mysqli_prepare($link, $sql)){
|
||||
// Bind variables to the prepared statement as parameters
|
||||
mysqli_stmt_bind_param($stmt, "si", $param_password, $param_id);
|
||||
|
||||
// Set parameters
|
||||
$param_password = password_hash($new_password, PASSWORD_DEFAULT);
|
||||
$param_id = $_SESSION["id"];
|
||||
|
||||
// Attempt to execute the prepared statement
|
||||
if(mysqli_stmt_execute($stmt)){
|
||||
// Password updated successfully. Destroy the session, and redirect to login page
|
||||
session_destroy();
|
||||
header("location: login.php");
|
||||
exit();
|
||||
} else{
|
||||
echo "Oops! Something went wrong. Please try again later.";
|
||||
}
|
||||
|
||||
// Close statement
|
||||
mysqli_stmt_close($stmt);
|
||||
}
|
||||
}
|
||||
|
||||
// Close connection
|
||||
mysqli_close($link);
|
||||
}
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Reset Password</title>
|
||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
|
||||
<style>
|
||||
body{ font: 14px sans-serif; }
|
||||
.wrapper{ width: 360px; padding: 20px; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="wrapper">
|
||||
<h2>Reset Password</h2>
|
||||
<p>Please fill out this form to reset your password.</p>
|
||||
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" method="post">
|
||||
<div class="form-group">
|
||||
<label>New Password</label>
|
||||
<input type="password" name="new_password" class="form-control <?php echo (!empty($new_password_err)) ? 'is-invalid' : ''; ?>" value="<?php echo $new_password; ?>">
|
||||
<span class="invalid-feedback"><?php echo $new_password_err; ?></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Confirm Password</label>
|
||||
<input type="password" name="confirm_password" class="form-control <?php echo (!empty($confirm_password_err)) ? 'is-invalid' : ''; ?>">
|
||||
<span class="invalid-feedback"><?php echo $confirm_password_err; ?></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="submit" class="btn btn-primary" value="Submit">
|
||||
<a class="btn btn-link ml-2" href="welcome.php">Cancel</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
@ -0,0 +1,94 @@
|
||||
<?php
|
||||
// Initialize the session
|
||||
session_start();
|
||||
|
||||
// Check if the user is already logged in, if yes then redirect him to welcome page
|
||||
if(isset($_SESSION["loggedin"]) && $_SESSION["loggedin"] === true){
|
||||
header("location: index.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
// Include config file
|
||||
require_once("model/db.php");
|
||||
|
||||
|
||||
// Define variables and initialize with empty values
|
||||
$username = $password = "";
|
||||
$username_err = $password_err = $login_err = "";
|
||||
|
||||
// Processing form data when form is submitted
|
||||
if($_SERVER["REQUEST_METHOD"] == "POST"){
|
||||
|
||||
// Check if username is empty
|
||||
if(empty(trim($_POST["prihlasovaciJmeno"]))){
|
||||
$username_err = "Please enter username.";
|
||||
} else{
|
||||
$username = trim($_POST["prihlasovaciJmeno"]);
|
||||
}
|
||||
// Check if password is empty
|
||||
if(empty(trim($_POST["prihlasovaciHeslo"]))){
|
||||
$password_err = "Please enter your password.";
|
||||
} else{
|
||||
$password = trim($_POST["prihlasovaciHeslo"]);
|
||||
}
|
||||
// Validate credentials
|
||||
if(empty($username_err) && empty($password_err)){
|
||||
// Prepare a select statement
|
||||
$sql = "SELECT id, nick, password FROM user WHERE nick = :username";
|
||||
if($stmt = $pdo->prepare($sql)){
|
||||
// Bind variables to the prepared statement as parameters
|
||||
$stmt->bindParam(":username", $param_username, PDO::PARAM_STR);
|
||||
|
||||
// Set parameters
|
||||
$param_username = trim($_POST["prihlasovaciJmeno"]);
|
||||
// Attempt to execute the prepared statement
|
||||
if($stmt->execute()){
|
||||
// Check if username exists, if yes then verify password
|
||||
if($stmt->rowCount() == 1){
|
||||
if($row = $stmt->fetch()){
|
||||
$id = $row["id"];
|
||||
$username = $row["nick"];
|
||||
$hashed_password = $row["password"];
|
||||
if(password_verify($password, $hashed_password)){
|
||||
// Password is correct, so start a new session
|
||||
session_start();
|
||||
|
||||
// Store data in session variables
|
||||
$_SESSION["loggedin"] = true;
|
||||
$_SESSION["id"] = $id;
|
||||
$_SESSION["username"] = $username;
|
||||
$_SESSION["wrongCr"] = false;
|
||||
|
||||
// Redirect user to welcome page
|
||||
//header("location: welcome.php");
|
||||
header("location: index.php");
|
||||
} else{
|
||||
// Password is not valid, display a generic error message
|
||||
$login_err = "Invalid username or password.";
|
||||
session_start();
|
||||
$_SESSION["wrongCr"] = true;
|
||||
header("location: index.php");
|
||||
}
|
||||
}
|
||||
} else{
|
||||
// Username doesn't exist, display a generic error message
|
||||
$login_err = "Invalid username or password.";
|
||||
session_start();
|
||||
$_SESSION["wrongCr"] = true;
|
||||
header("location: index.php");
|
||||
}
|
||||
} else{
|
||||
session_start();
|
||||
$_SESSION["wrongCr"] = true;
|
||||
header("location: index.php");
|
||||
}
|
||||
|
||||
// Close statement
|
||||
unset($stmt);
|
||||
}
|
||||
}
|
||||
|
||||
// Close connection
|
||||
unset($pdo);
|
||||
}
|
||||
?>
|
Loading…
Reference in New Issue