Agile Daily Scrum App | How to create a basic “C.R.U.D. App” | Php & Pdo & SQL | RDB (One To Many) & OOP & Procedural (Login & Register & Users)

To begin with, a basic crud application is quite a good way to create an internal app for scrum teams.

We will create the tables in database (SQL) then create “Log In” & “Register” & “Daily Notes” & “Users” and other pages with PHP.

Object-Oriented:

Demo App: https://agile.herokuapp.com/users.php

Github: https://github.com/mertkgursoy/agile-scrum-daily-app-oop

Create SQL Database:

“Relational Database (RDB) — One to Many Relationship”

In order to use the app we need to create database and tables first.

1) Create a new Database “agile_scrum_database”.

CREATE DATABASE agile_scrum_database;

2) Grant “agile_scrum_database” access to the user with a password(i.e. theUserName & thePass) in MySQL. (if needed)

GRANT ALL ON agile_scrum_database.* TO 'theUserName'@'localhost' IDENTIFIED BY 'thePass';GRANT ALL ON agile_scrum_database.* TO 'theUserName'@'127.0.0.1' IDENTIFIED BY 'thePass';

3) Create “Teams” Table in this “agile_scrum_database”.

“teams” Table:

CREATE TABLE teams (team_id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,team_name VARCHAR(128) UNIQUE,team_created_date VARCHAR(128),admin_email VARCHAR(128),admin_name VARCHAR(128),INDEX USING BTREE (team_name)) ENGINE=InnoDB CHARSET=utf8;

4) Create “Users” Table in this “agile_scrum_database”.

“users” Table: One To Many

CREATE TABLE users (user_id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,email VARCHAR(128) UNIQUE,name VARCHAR(128),team_name VARCHAR(128),is_admin INTEGER NOT NULL,is_active INTEGER NOT NULL,password VARCHAR(128),team_id INTEGER NOT NULL,INDEX USING BTREE (email),CONSTRAINT FOREIGN KEY (team_id) REFERENCES teams (team_id) ON DELETE CASCADE ON UPDATE CASCADE) ENGINE=InnoDB CHARSET=utf8;

5) Create “Daily Notes” Table in this “agile_scrum_database”.

“daily” Table: One To Many

CREATE TABLE daily (daily_id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,wdydy VARCHAR(128),wwydt VARCHAR(128),itai VARCHAR(128),is_note_active INTEGER NOT NULL,daily_created_date VARCHAR(128),team_id INTEGER NOT NULL,user_id INTEGER NOT NULL,CONSTRAINT FOREIGN KEY (team_id) REFERENCES teams (team_id) ON DELETE CASCADE ON UPDATE CASCADE,CONSTRAINT FOREIGN KEY (user_id) REFERENCES users (user_id) ON DELETE CASCADE ON UPDATE CASCADE) ENGINE=InnoDB CHARSET=utf8;

2) Create “Classes” and “Php Files” | OOP & PHP:

We need to create a pdo.php file to connect our application to DB via pdo.

pdo.php

https://github.com/mertkgursoy/agile-scrum-daily-app-oop/blob/main/pdo.php

  • Let’s create authentication mechanism and other required php files below.
  • It should be private and triggered by the constructor.

class.php

https://github.com/mertkgursoy/agile-scrum-daily-app-oop/blob/main/class.php

  • Now, “Auth class” in pdo.php file should be extended (An inherited class is defined by using the extends keyword) to the following classes below in class.php file so that we will be able to connect sql database and send requests to retrieve data from database.
  • i.e; $this->authRun()->prepare($selectUserSqlQuery);

login.php

https://github.com/mertkgursoy/agile-scrum-daily-app-oop/blob/main/login.php

  • And then this classes should be added in related php files like this login.php below.

register.php

daily-scrum.php

https://github.com/mertkgursoy/agile-scrum-daily-app-oop/blob/main/daily-scrum.php

daily-scrum-form.php

https://github.com/mertkgursoy/agile-scrum-daily-app-oop/blob/main/daily-scrum-form.php

users.php

https://github.com/mertkgursoy/agile-scrum-daily-app-oop/blob/main/users.php

index.php

https://github.com/mertkgursoy/agile-scrum-daily-app-oop/blob/main/index.php

logout.php

https://github.com/mertkgursoy/agile-scrum-daily-app-oop/blob/main/logout.php

Templates & Asset Folders

Secondly, we’ll create “templates” folder in our project folder than create header.php and footer.php files. Also an “asset” named folder will be created in the project folder and “main.css” file will be created in it.

main.css

header.php

https://github.com/mertkgursoy/agile-scrum-daily-app-oop/blob/main/templates/header.php

footer.php

https://github.com/mertkgursoy/agile-scrum-daily-app-oop/blob/main/templates/footer.php

If it looks so complicated and looking for an easier way you can check the following procedural code snippets below.

— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —

— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —

Procedural Way & Spaghetti Code :

Demo App: https://daily-scrum-tool.herokuapp.com/register.php

Gitlab:https://gitlab.com/mertkgursoy/dailyscrumtool

Github:https://github.com/mertkgursoy/DailyScrumTool

1) MySQL:

In order to use MySQL firstly we need to create database and table by using the following statements below

Create a new Database “daily_scrum_database”.

CREATE DATABASE daily_scrum_database;

Grant “daily_scrum_database” access to the user with a password(i.e. theUserName & thePass) in MySQL.

GRANT ALL ON daily_scrum_database.* TO 'theUserName'@'localhost' IDENTIFIED BY 'thePass';GRANT ALL ON daily_scrum_database.* TO 'theUserName'@'127.0.0.1' IDENTIFIED BY 'thePass';

In “pdo.php” file, we will be using it later this credentials to connect and access the “daily_scrum_database” from project to MySQL.

Create “Users” Table in this “daily_scrum_database”.

“users” Table:

CREATE TABLE users (
user_id INTEGER NOT NULL
AUTO_INCREMENT KEY,
name VARCHAR(128),
email VARCHAR(128),
password VARCHAR(128),
INDEX(email)
) ENGINE=InnoDB CHARSET=utf8;

Insert a user in this “Users” table (with md5 hash password).

INSERT INTO users (name,email,password) VALUES ('Gursoy','test@mertkadirgursoy.com',
' !!!!!MD5 HASH THIS PASSWORD!!!!! ');
(Please md5 hashed password use above)

Create “Daily Scrum” Table in this “daily_scrum_database”.

“daily_scrum_table” Table:

CREATE TABLE daily_scrum_table (auto_id INT UNSIGNED NOT NULL AUTO_INCREMENT KEY,theName VARCHAR(128),theEmail VARCHAR(128),theDate VARCHAR(128),theWhatDidYouDoYesterday VARCHAR(128),theWhatWillYouDoToday VARCHAR(128),theIsThereAnyImpediment VARCHAR(128));

Insert a daily note in this “Daily Scrum Table” table.

INSERT INTO daily_scrum_table (theName,theEmail, theDate,theWhatDidYouDoYesterday,theWhatWillYouDoToday,theIsThereAnyImpediment) VALUES ('Gursoy','test@mertkadirgursoy.com', '21.11.2021','Yesterday', 'Today', 'Impediment');

2) PHP & PDO:

index.php

Firstly we need to create a new project folder than create index.php and redirect the user to login.php.

<?php// Headerheader("Location: login.php");?>

— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —

Templates & Asset Folders

Secondly, we’ll create “templates” folder in our project folder than create header.php and footer.php files. Also an “asset” named folder will be created in the project folder and “main.css” file will be created in it.

— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —

header.php

<html><head><title>Daily Scrum Tool</title><meta name="author" content="MertKGursoy"><script>console.log("author: Mert Kadir Gürsoy");</script><link rel="stylesheet" type="text/css" href="asset/main.css"><script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script><link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"></head><body>

— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —

footer.php

</body><footer></footer></html>

— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —

logout.php

To be able to log out and end the session, we need the following code in this page.

<?phpsession_start();session_destroy();header("location:login.php");?>

— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —

pdo.php

Now, we need to create a pdo.php file to connect our application with MySQL.

<?php$hostName = "localhost";$dbName = "daily_scrum_database";$userName = "theUserName";$password = "thePass";try {$pdo = new PDO("mysql:host=$hostName;dbname=$dbName",$userName,$password);$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);} catch(PDOException $e) {echo "Connection failed: " . $e->getMessage();}?>

— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —

register.php

A new user will be created with this register.php file.

To create this php file we need add the following code snippet below

1) // Add Header

<?phpinclude 'templates/header.php';?>

2) // Start Session

<?phpsession_start();

3)// Add PDO Config

require_once "pdo.php";

4)// Add User Into Users Table

if ( isset($_POST['name']) && isset($_POST['email']) && isset($_POST['password'])) {

5) //Set Email From Post Email

// Set Email From Post Email$email = $_POST['email'];

6) //Check Email is really Email

if (!filter_var ($email, FILTER_VALIDATE_EMAIL)) {$error = "Invalid email format";echo "<span>  Invalid Email Address! </span>";}

7) //Check If Users Exists and Registered Before

$query = $pdo->prepare("  SELECT * FROM users WHERE email = ? ");$query->execute([$email]);$result = $query->rowCount();if ($result > 0 ) {$error = "<span> Email Already Exists! Please try again. </span>";echo "<span>  Email Already Exists! Please try again.  </span>";}

7) //Add this user if we do not have any issue above. “empty error” means we passed the error conditions above.

if (empty($error)) {

8) //Add User in Database Users Table

$password = $_POST["password"];$hash = md5($password);$insertUserSqlQuery = "INSERT INTO users (name, email, password)VALUES (:name, :email, :password)";echo("<pre>\n".$insertUserSqlQuery."\n</pre>\n");$stmtTheNewUser = $pdo->prepare($insertUserSqlQuery);$stmtTheNewUser->execute(array(':name' => $_POST['name'],':email' => $_POST['email'],':password' => $hash));

9) //Set the user email in session and go to tool page

$_SESSION["email"] = $_POST["email"];

10) //Taking now logged in time.

$_SESSION['start'] = time();

11) //Ending a session in 30 minutes from the starting time.

$_SESSION['expire'] = $_SESSION['start'] + (30 * 60);

12)// Redirect if url from register page to tool page.

header("Location: daily-scrum-form.php");

13)// Redirect url from register page to login form.

if ( isset($_POST['loginForm']) ) {header("Location: login.php");}

14) // HTML Register Form

<div class="container-the100"><div class="wrap-the100"><form method="post" class="the100-form validate-form"><span class="the100-form-title">Create User</span><div class="wrap-input100 validate-input"><input style="height: 60px;" class="input100" placeholder="Name" required data-validate = "This field is required" type="text" name="name"><span class="focus-input100"></span></div><div class="wrap-input100 validate-input"><input  style="height: 60px;" class="input100" placeholder="Email" required data-validate = "This field is required" type="email" name="email"><span class="focus-input100"></span></div><div class="wrap-input100 validate-input"><input style="height: 60px;" class="input100" placeholder="Password"  required data-validate = "This field is required" type="password" name="password"><span class="focus-input100"></span></div><div style="padding-top: 25px; padding-bottom:0px" class="container-the100-form-btn"><button style="margin-right: 15px; margin-left:15px;" type="submit" value="Add New" class="the100-form-btn">Create</button><span></span></div></form>    <br/><p style="padding:0px; padding-bottom: 5px;" class="container-the100-form-btn">or</p><div style="padding:0px;" class="container-the100-form-btn"><a href="login.php">Log In</a></div></div></div>

15) // Add footer in this page.

<?phpinclude "templates/footer.php"; // Footer?>

— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —

login.php

With the user credentials that we created above, we will log in and redirect to daily-scrum-form.php.

1) // Add Header

include 'templates/header.php';

2) // Start Session

session_start();

3) // Add PDO Config

require_once "pdo.php";

4) // Check Submit Button Clicked & Inputs Filled Correctly //

if ( !empty($_POST['email']) &&  isset($_POST['email']) && isset($_POST['password']) && !empty($_POST['password']) ) {

5) // Check User Exist or Not In Users Table — Try To Select User From Users Table //

$selectUserSqlQuery = "SELECT name FROM usersWHERE email = :em AND password = :pw";// echo "<p>$selectUserSqlQuery</p>\n";$stmt = $pdo->prepare($selectUserSqlQuery);$password = $_POST["password"];$hash = md5($password);$stmt->execute(array(':em' => $_POST['email'],':pw' => $hash));$row = $stmt->fetch(PDO::FETCH_ASSOC);// var_dump($row);

6) // Check If User Exists Log In and Redirect To The Success Page or Display Error Message //

if ( $row === FALSE ) {echo "<h1 style='color: #e4ff00;'>Login incorrect.</h1>\n";$password = $_POST["password"];$hash = md5($password);// echo $hash;} else {echo "<p>Login success.</p>\n";

7) // Set The User Email In Session And Go To DailyScrum Page //

$_SESSION["email"] = $_POST["email"];

8) // Retrieve User Name By Session Email

$theUserSessionEmail = $_POST["email"];$SqlQueryToRetrieveUserData = $pdo->prepare('SELECT * FROM users WHERE email = ?');$SqlQueryToRetrieveUserData->execute(array($theUserSessionEmail));$userData = $SqlQueryToRetrieveUserData->fetch(PDO::FETCH_ASSOC);

9) // Add this user if we do not have any issue above. “empty error” means we passed the error conditions above. //

if(!empty($userData)) {

10) // Set user name in Session

$_SESSION["name"] = $userData["name"];

11) // Taking now logged in time.

$_SESSION['start'] = time();

12) // Ending a session in 30 minutes from the starting time.

$_SESSION['expire'] = $_SESSION['start'] + (30 * 60);

13)// Redirect to Form page

header("Location: daily-scrum-form.php");

14)// Redirect to Register Form Page

if ( isset($_POST['register']) ) {header("Location: register.php");}

15)// HTMLLog In Form Page

<div class="container-the100"><div class="wrap-the100"><form method="post" class="the100-form validate-form"><span class="the100-form-title">Daily Scrum Tool</span><div class="wrap-input100 validate-input"><input style="height: 60px;" class="input100" placeholder="Email"  required data-validate = "This field is required" type="email" name="email"><span class="focus-input100"></span></div><div class="wrap-input100 validate-input"><input style="height: 60px;" class="input100" placeholder="Password"  required  data-validate = "This field is required" type="password" name="password"><span class="focus-input100"></span></div><div style="padding-top: 25px; padding-bottom:15px" class="container-the100-form-btn"><button style="margin-right: 15px; margin-left:15px;"    type="submit" value="Login" class="the100-form-btn">Log In</button><span></span><!--button style="margin-right: 15px; margin-left:15px;" class="the100-form-btn"><a href="<?php echo($_SERVER['PHP_SELF']);?>">Refresh</a></button>--></div></form><p style="padding:0px; padding-bottom: 5px;" class="container-the100-form-btn">or</p><div style="padding:0px;" class="container-the100-form-btn"><a href="register.php">Create A New User</a></div></div></div>

16) Add Footer

include "templates/footer.php"; // Footer

— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —

daily-scrum-form.php

Daily-scrum-form.php will be used for creating a daily note.

1)Add header

include 'templates/header.php';

2) // Start Session

session_start();

3) // Add PDO Config

require_once "pdo.php";

4) Check if Session and the email of the user Exist

if(isset($_SESSION["email"])){

5) // Check if session expired redirect it to login page

$now = time(); // Checking the time now when home page starts.if ($now > $_SESSION['expire']) {session_destroy();echo "Your session has expired! <a href='http://localhost/somefolder/login.php'>Login here</a>";header("location:login.php");}else {

6) // Retrieve User Name By Session Email

$theUserSessionEmail = $_SESSION['email'];$SqlQueryToRetrieveUserData = $pdo->prepare('SELECT * FROM users WHERE email = ?');$SqlQueryToRetrieveUserData->execute(array($theUserSessionEmail));$userData = $SqlQueryToRetrieveUserData->fetch(PDO::FETCH_ASSOC);if(!empty($userData)) {

7) // Add DailyNotes Into daily_scrum_table //

if ( !empty($_POST['theWhatDidYouDoYesterday']) &&  isset($_POST['theWhatDidYouDoYesterday']) && !empty($_POST['theWhatWillYouDoToday'])  &&  isset($_POST['theWhatWillYouDoToday']) && !empty($_POST['theIsThereAnyImpediment']) && isset($_POST['theIsThereAnyImpediment']) && !empty($_SESSION['email']) && isset($_SESSION['email'])  )  {$selectDailyNoteSqlQuery = "INSERT INTO daily_scrum_table (theName, theEmail, theDate, theWhatDidYouDoYesterday, theWhatWillYouDoToday, theIsThereAnyImpediment)VALUES (:theName, :theEmail, :theDate, :theWhatDidYouDoYesterday, :theWhatWillYouDoToday, :theIsThereAnyImpediment)";//echo("<pre>\n".$selectDailyNoteSqlQuery."\n</pre>\n");$stmtDailyNotes = $pdo->prepare($selectDailyNoteSqlQuery);$stmtDailyNotes->execute(array(':theName' => $userData['name'],':theEmail' => $_SESSION['email'],':theDate' => date("d-m-Y"), /* $_POST['theDate'], */':theWhatDidYouDoYesterday' => $_POST['theWhatDidYouDoYesterday'],':theWhatWillYouDoToday' => $_POST['theWhatWillYouDoToday'],':theIsThereAnyImpediment' => $_POST['theIsThereAnyImpediment']));

8) Redirect to Table Page to view the added data

header("Location: daily-scrum.php");

9) HTML Daily Scrum Form

<div class="container-the100"><div class="wrap-the100"><form method="post" class="the100-form validate-form"><span class="the100-form-title">Create A Daily Note<?phpecho '<h3 style="color: #403866;">Hello '.$userData["name"].'</h3>';?></span><!--<p>Name:<input type="text" name="theName" size="40"></p>--><!--<p>Date:<input type="text" name="theDate"></p>--><div class="wrap-input100 validate-input"><input class="input100" placeholder="Yesterday: What did you do yesterday?" required data-validate = "This field is required" type="text" name="theWhatDidYouDoYesterday"><span class="focus-input100"></span></div><div class="wrap-input100 validate-input"><input class="input100" placeholder="Today: What will you do today?" required data-validate = "This field is required" type="text" name="theWhatWillYouDoToday"><span class="focus-input100"></span></div><div class="wrap-input100 validate-input"><input class="input100" placeholder="Impediment: Is there any impediment?" required data-validate = "This field is required" type="text" name="theIsThereAnyImpediment"><span class="focus-input100"></span></div><div style="padding-top: 25px; padding-bottom:15px" class="container-the100-form-btn"><button type="submit" value="Add New" class="the100-form-btn">Create</button><span></span></div></form><p style="padding:0px; padding-bottom: 5px;" class="container-the100-form-btn">or</p><div style="padding:0px;" class="container-the100-form-btn"><a href="daily-scrum.php">Daily Notes</a><p style="color: transparent;">--<span style="color: #d4d4e2;font-weight: bold;">|</span>--</p><a href="users.php">Scrum Team</a></div></div></div>

10) Add Footer

include "templates/footer.php";

— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —

daily-scrum.php

daily-scrum.php will be used for listing a daily notes in a table.

1)Add Header

include 'templates/header.php';

2)Start Session

session_start();

3) // Add PDO Config

require_once "pdo.php";

4)// Check If Session And User Exists

if(isset($_SESSION["email"]))  {

5) // Check if session expired redirect it to login page

$now = time();if ($now > $_SESSION['expire']) {session_destroy();echo "Your session has expired! <a href='http://localhost/somefolder/login.php'>Login here</a>";header("location:login.php");}else {

6) // Retrieve User Name By Session Email

$theUserSessionEmail = $_SESSION['email'];$SqlQueryToRetrieveUserData = $pdo->prepare('SELECT * FROM users WHERE email = ?');$SqlQueryToRetrieveUserData->execute(array($theUserSessionEmail));$userData = $SqlQueryToRetrieveUserData->fetch(PDO::FETCH_ASSOC);if(!empty($userData)) {echo '<br> <br> <h1 style="color: white;">Daily Scrum Standup Notes</h1>';echo '<br><h3 style="margin-top: 0px !important; color: white;">Hello '.$userData["name"]. '</h3>';}

7) // Delete USER can only delete its own rows AND if it’s added today from daily_scrum_table //

if ( isset($_POST['delete']) && isset($_POST['auto_id']) && isset($_POST["theEmail"]) ) {$selectDailyNoteSqlQuery = "DELETE FROM daily_scrum_table WHERE (auto_id = :zip AND theEmail = :theEmail AND theDate = :theDate)" ;// echo "<pre>\n$selectDailyNoteSqlQuery\n</pre>\n";$stmtDailyNotes = $pdo->prepare($selectDailyNoteSqlQuery);$stmtDailyNotes->execute(array(':zip' => $_POST['auto_id'],":theEmail" => $_SESSION["email"],":theDate" => date("d-m-Y")));}

8) // Diplay Daily Notes In HTML Table

$stmtDailyNotes = $pdo->query("SELECT theName, theDate, theEmail, theWhatDidYouDoYesterday, theWhatWillYouDoToday, theIsThereAnyImpediment, auto_id FROM daily_scrum_table");$rows = $stmtDailyNotes->fetchAll(PDO::FETCH_ASSOC);

9) HTML Daily Scrum Table

<div class="container-the100"><div  class="wrap-the100"><div class="table-wrap"><table border="1" class="table table-striped"><thead><tr><th> User Name</th><th> Date </th><th> Yesterday </th><th> Today </th><th> Impediment </th><th> </th></tr></thead><tbody><?phpforeach ( $rows as $row ) {echo "<tr><td>";echo($row['theName']);echo("</td><td>");echo($row['theDate']);echo("</td><td>");echo($row['theWhatDidYouDoYesterday']);echo("</td><td>");echo($row['theWhatWillYouDoToday']);echo("</td><td>");echo($row['theIsThereAnyImpediment']);echo("</td><td>");echo('<form method="post"><input type="hidden" ');echo('name="theEmail" value="'.$row['theEmail'].'">'."\n");echo('<input type="hidden" ');echo('name="auto_id" value="'.$row['auto_id'].'">'."\n");if ($_SESSION["email"] === $row["theEmail"] && $row["theDate"] ===  date("d-m-Y")) {echo('<input style="background: none; color: #a10000;     font-weight: bold;" type="submit" value="Remove" name="delete">');} else {echo('<input style="background: none; color: transparent;" type="submit" value="Remove" name="delete">');}echo("\n</form>\n");echo("</td></tr>\n");}?></tbody></table></div><p style="padding:0px; padding-bottom: 5px;" class="container-the100-form-btn"><span style="color: transparent;font-weight: bold;"></span>or</p><div style="padding:0px;" class="container-the100-form-btn"><a href="daily-scrum-form.php">Create Note</a><p style="color: transparent;">----<span style="color: #d4d4e2;font-weight: bold;">|</span>----</p><a href="users.php">Scrum Team</a></div></div></div>

10) Add Footer

include "templates/footer.php"; // Footer

— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —

user.php

This page will be used for listing the users of this tool in table.

1)Add Header

include 'templates/header.php';

2)Start Session

session_start();

3)Add pdo

require_once "pdo.php";if(isset($_SESSION["email"])){

4) // Check if session expired redirect it to login page

$now = time(); // Checking the time now when home page starts.if ($now > $_SESSION['expire']) {session_destroy();echo "Your session has expired! <a href='http://localhost/somefolder/login.php'>Login here</a>";header("location:login.php");}else {

5) // Retrieve User Name By Session Email

$theUserSessionEmail = $_SESSION['email'];$SqlQueryToRetrieveUserData = $pdo->prepare('SELECT * FROM users WHERE email = ?');$SqlQueryToRetrieveUserData->execute(array($theUserSessionEmail));$userData = $SqlQueryToRetrieveUserData->fetch(PDO::FETCH_ASSOC);if(!empty($userData)) {echo '<br> <br><h1 style="color: white;">Scrum Team</h1>';echo '<br><h3 style="color: white;">Hello '.$userData["name"]. ' </h3>';}

6) // Delete rows only User Can Delete its own row from daily_scrum_table //

if ( isset($_POST['delete']) && isset($_POST['user_id']) && isset($_POST['theEmail']) ) {if ( $_POST['theEmail'] == $_SESSION['email'] ) {$selectUserSqlQuery = "DELETE FROM users WHERE (user_id = :zip AND email = :email)";echo "<pre>\n$selectUserSqlQuery\n</pre>\n";$stmtUser = $pdo->prepare($selectUserSqlQuery);$stmtUser->execute(array(':zip' => $_POST['user_id'],':email' => $_SESSION['email']));header("location:logout.php");}}

7) // Diplay Users In HTML Table//

$stmtUser = $pdo->query("SELECT name, email, password, user_id FROM users");$rowsUser = $stmtUser->fetchAll(PDO::FETCH_ASSOC);

8)HTML users Table

<div class="container-the100"><div  class="wrap-the100"><div class="table-wrap"><table border="1" class="table table-striped"><thead><tr><th> User Name</th><th> Email </th><th> Password </th><th> </th></tr></thead> <tbody><?phpforeach ( $rowsUser as $row ) {echo "<tr><td>";echo($row['name']);echo("</td><td>");echo($row['email']);echo("</td><td class='hidetext'>");echo('****');echo("</td><td>");echo('<form method="post"><input type="hidden" ');echo('name="user_id" value="'.$row['user_id'].'">'."\n");echo('<input type="hidden"');echo('name="theEmail" value="'.$row['email'].'">'."\n");if ($_SESSION["email"] === $row["email"]) {echo('<input style="background: none; color: #a10000;     font-weight: bold;"type="submit" value="Remove" name="delete">');} else {echo('<input style="background: none; color: transparent;" type="submit" value="Remove" name="delete">');}echo("\n</form>\n");echo("</td></tr>\n");}?></tbody></table></div><p style="padding:0px; padding-bottom: 5px;" class="container-the100-form-btn"><span style="color: transparent;font-weight: bold;">-----</span>or</p><div style="padding:0px;" class="container-the100-form-btn"><a href="daily-scrum.php">Daily Notes</a><p style="color: transparent;">----<span style="color: #d4d4e2;font-weight: bold;">|</span>----</p><a href="logout.php">Log Out</a></div></div></div>

9)Add Footer

include "templates/footer.php"; // Footer

— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —

--

--

Senior Technical Project Manager & Web Developer https://www.linkedin.com/in/mert-gursoy/

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store