PHP Code-Along Series (Part 3)
The final part of this series can serve as an extension to the activity done in Practical 9. Here, we will be going through how to utilize credentials stored in a database in simulating a mock login and logout functionality.
Video
Prep Files
DBConnection.php
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbName = "newDB";
$conn = new mysqli($servername, $username, $password, $dbName);
if($conn->connect_error) die("Connection failed: " . $conn->connect_error);
userTable.sql
DROP TABLE IF EXISTS `newDB`.`User`;
CREATE TABLE `newDB`.`User` (
`id` INT NOT NULL AUTO_INCREMENT,
`username` VARCHAR(20) NOT NULL,
`password` VARCHAR(100) NOT NULL,
`name` VARCHAR(100) NOT NULL,
PRIMARY KEY(`id`)
);
INSERT INTO `newDB`.`User` (`username`, `password`, `name`) VALUES
('110358', 'Weloveqwerty123', 'Person');
Warning
The code-along video uses a different username, exercise caution if you plan on using this username instead.