Sunday, February 28, 2021

Square and Cube a Number in Python

Square and Cube a Number in Python

 A simple program to display the square and cube a number using Python.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.



Program Listing


i = 0
print(f"Number Squared Cube")

while i < 8:
i = i + 1
squared = i * i
cube = i * i * i
print(f"{i} {squared} {cube}")

Friday, February 26, 2021

Area of the Dining Table in C#

Area of the Dining Table in C#

 A simple program that I wrote to solve the area of the dining table using C# programming language.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.


My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod City I also accepting computer repair, networking, and Arduino Project development at a very affordable price. My website is www.jakerpomperada.blogspot.com and www.jakerpomperada.com

If you like this video please click the LIKE button, SHARE, and SUBSCRIBE to my channel.

Your support on my channel is highly appreciated.

Thank you very much.





Program Listing


using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;


namespace ConsoleApplication1

{

    class Program

    {

        static void Main(string[] args)

        {

            double length, breadth, area;


            Console.WriteLine("\n");

            Console.Write("\tArea of the Dining Table in C# ");

            Console.WriteLine("\n");

            Console.Write("\tEnter length of Dining Table : ");

            length = Convert.ToDouble(Console.ReadLine());

            Console.WriteLine("\n");

            Console.Write("\tEnter breadth of Dining Table : ");

            breadth = Convert.ToDouble(Console.ReadLine());

            area = length * breadth;

            Console.WriteLine("\n");

            Console.WriteLine("\tArea of the Dining Tabe : " + area);

            Console.WriteLine("\n");

            Console.WriteLine("\tEnd of Program");

            Console.ReadKey();

        }

    }

}


Wednesday, February 24, 2021

Do You Want To Try Again in Python

Do You Want to Try Again in Python

 In this article I would like to share with you how to add two numbers and ask the user if the user would like to try again using while statement in Python programming language.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

dfdfdfdfdfdf22323232

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod City I also accepting computer repair, networking, and Arduino Project development at a very affordable price. My website is www.jakerpomperada.blogspot.com and www.jakerpomperada.com

If you like this video please click the LIKE button, SHARE, and SUBSCRIBE to my channel.

Your support on my channel is highly appreciated.

Thank you very much.





Program Listing



res = "y"

while res.lower() == "y":

# Store input numbers
num1 = int(input('Enter first number: '))
num2 = int(input('Enter second number: '))

# Add two numbers
sum = num1 + num2

# Display the sum
print('The sum of {0} and {1} is {2}'.format(num1, num2, sum))
res = str(input("Do you want to try again? (Y/N) : "
""))
print();

Sum and Product of Two Numbers in C#

Sum and Product of Two Numbers in C# Using Console

 A simple program that I wrote to ask the user to give two numbers and then the program will compute the sum and product of two numbers using C# programming language.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod City I also accepting computer repair, networking, and Arduino Project development at a very affordable price. My website is www.jakerpomperada.blogspot.com and www.jakerpomperada.com

If you like this video please click the LIKE button, SHARE, and SUBSCRIBE to my channel.

Your support on my channel is highly appreciated.

Thank you very much.




Program Listing

Prorgam.cs

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;


namespace Sum_and_Product_of_Two_Numbers

    


{

    class Program

    {

        public static int Sum(int num1, int num2)

        {

            int total;

            total = num1 + num2;

            return total;

        }


        public static int Product(int num1, int num2)

        {

            int multiply;

            multiply = num1 * num2;

            return multiply;

        }

        

        static void Main(string[] args)

        {

            Console.Write("\n\nSum and Product of Two Numbers in C# Using Console\n");

            Console.Write("--------------------------------------------------\n");

            Console.Write("\tEnter a number: ");

            int n1 = Convert.ToInt32(Console.ReadLine());

            Console.Write("\tEnter another number: ");

            int n2 = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine("\n\tThe sum of {0}  and {1} is : {2} \n",n1,n2, Sum(n1, n2));

            Console.WriteLine("\n\tThe product of {0} and {1} is : {2} \n",n1,n2, Product(n1, n2));

            Console.WriteLine("\tEnd of Program");

            Console.WriteLine("\n");

            Console.ReadKey();

        }

    }

}



Body Mass Index in Python

Tuesday, February 23, 2021

Body Mass Index in Python

 In this article, I will share with you a program that I wrote to solve the body mass index using Python programming language.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod City I also accepting computer repair, networking, and Arduino Project development at a very affordable price. My website is www.jakerpomperada.blogspot.com and www.jakerpomperada.com

If you like this video please click the LIKE button, SHARE, and SUBSCRIBE to my channel.

Your support on my channel is highly appreciated.

Thank you very much.





Program Listing



# body_mass.py
# Mr. Jake Rodriguez Pomperada, MAED-IT, MIT
# www.jakerpomperada.com www.jakerpomperada.blogspot.com
# jakerpomperada@gmail.com
# February 22, 2021 1:59 PM Monday
# Bacolod City, Negros Occidental

print()
print("\tBody Mass Index in Python");
print()
# Define the constants
METER = 100

# Read the inputs from user
height = float(input("\tGive your height in Centimeters: "))
weight = float(input("\tGive your weight in Kilograms: "))

temp = height / METER
# Calculate the BMI
bmi = weight / (temp * temp)

# Display the result
print()
print("\tYour Body Mass Index is: ", "%d" % (bmi))
print()
print("\tEND OF PROGRAM");
print()

Monday, February 22, 2021

String Format in Python

String Format in Python

 In this article I will show you how to create and use string format in Python.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod City I also accepting computer repair, networking, and Arduino Project development at a very affordable price. My website is www.jakerpomperada.blogspot.com and www.jakerpomperada.com

If you like this video please click the LIKE button, SHARE, and SUBSCRIBE to my channel.

Your support on my channel is highly appreciated.

Thank you very much.




Program Listing

# String format in Python
# Jake R. Pomperada,MAED-IT, MIT
# www.jakerpomperada.com and www.jakerpomperada.blogspot.com

name = "Julianna Rae Pomperada"
food = "Pizza"
game = "Roblox"
age = "6"
text1 = "My name is {} I love {} and playing {}. I am {} years old"
info1 = text1.format(name,food,game, age)
print(info1)

Simple Weekly Payroll in Python

Simple Weekly Payroll in Python

 Create a Simple Weekly Payroll.

The program should accept the following inputs:
- Employee Name
- Number of hours rendered
- Rate per hour
- GSIS Premium Contribution
- PhilHealth Contribution
- Housing Loan
- Tax percentage rate (example input: 25, the program will treat it as 25%).

The program should compute the weekly gross salary, total deductions
and weekly net salary.


I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod City I also accepting computer repair, networking, and Arduino Project development at a very affordable price. My website is www.jakerpomperada.blogspot.com and www.jakerpomperada.com

If you like this video please click the LIKE button, SHARE, and SUBSCRIBE to my channel.

Your support on my channel is highly appreciated.

Thank you very much.





Program Listing



# day1prac1.py
# Mr. Jake Rodriguez Pomperada, MAED-IT, MIT
# www.jakerpomperada.com www.jakerpomperada.blogspot.com
# jakerpomperada@gmail.com
# February 22, 2021 1:59 PM Monday
# Bacolod City, Negros Occidental

print()
print("\tSIMPLE WEEKLY PAYROLL");
print()
name = str(input("Employees Name : "))
hour = int(input("Number of hours rendered : "))
rate =
float(input("Rate per hour : "))
gsis =
float(input("GSIS Premium Contribution : "))
phil =
float(input("PhilHealth Contribution : "))
loan =
float(input("Housing Loan : "))
tax =
float(input("Tax Rate : "))

gross = hour * rate
deductions = (gross * (tax *
0.01)) + gsis + phil + loan
netsalary = gross - deductions

print();
print("\tDisplay Payroll Results");
print();
print("Gross Salary = {:5.2f}" .format(gross))
print("Total deductions = {:5.2f}" .format(deductions))
print();
print("Net Salary = {:5.2f}".format(netsalary) )
print();
print("\tEND OF PROGRAM");
print();

Sunday, February 21, 2021

Prime Number Checker in PHP

Prime Number Checker in PHP

 A simple prime number check written using PHP, HTML and CSS I hope you will find my work useful.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod City I also accepting computer repair, networking, and Arduino Project development at a very affordable price. My website is www.jakerpomperada.blogspot.com and www.jakerpomperada.com

If you like this video please click the LIKE button, SHARE, and SUBSCRIBE to my channel.

Your support on my channel is highly appreciated.

Thank you very much.





Program Listing


style.css

* {

    box-sizing: border-box;

}


body {

    font-family: "Calibri", sans-serif;

    background: #e2e1e0;

    color: #111;

}


main {

    position: absolute;

    top: 50%;

    left: 50%;

    transform: translate(-50%, -50%);

}


.container {

    padding: 50px;

    width: 600px;

    background: #fff;

    text-align: left;

    border-radius: 20px;

    box-shadow: 0 0 60px rgba(0,0,0,0.05);

}


h1 {

    margin: 0;

    line-height: 0.9;

}


h2 {

    margin: 0;

}


.title {

    display: block;

    margin: 0 0 40px;

    text-align: center;

}


.txtbox {

    display: block;

    background: #f1f1f1;

    width: 100%;

    margin: 0 0 20px 0;

    padding: 15px;

    border: none;

    font-size: 20px;

    border-radius: 8px;

    font-family: "Calibri", sans-serif;

    text-align: center;

}


.txtbox:hover,

.txtbox:focus {

    background: #e0e0e0;

}


.btnWrapper {

    display: inline-flex;

}


.btn {

    background: #673ab7;

    color: #fff;

    padding: 15px;

    width: 250px;

    opacity: 0.9;

    outline: none;

    font-size: 20px;

    text-transform: uppercase;

    border: none;

    text-decoration: none;

    text-align: center;

    font-family: "Calibri", sans-serif;

    cursor: pointer;

    text-decoration: none;

    display: block;

}


.btn:hover {

    opacity: 1;

}


.btnReset {

    background: #ff5722;

    border-radius: 8px 0 0 8px;

}


.btnConvert {

    border-radius: 0 8px 8px 0;

}


.answer {

    width: 100%;

    padding: 20px;

    text-align: center;

    font-size: 25px;

    font-weight: bold;

    background: #9e9e9e;

    color: #fff;

    line-height: 1;

    margin-top: 20px;

    border-radius: 8px;

}


index.php


<?php

    $out = $input = "";

    if ($_POST) {

        $input=$_POST['txtNum'];


        for ($i = 2; $i <= $input-1; $i++) {

            if ($input % $i == 0) {

                $value= true;

            }

        }

        if (empty($value) && $input != 1) {

            $out = '<div class="answer">'.$input.' is a Prime Number </div>';

        }  else {

            $out = '<div class="answer">'.$input.' is not a Prime Number</div>';

        }

    }

?>

<!DOCTYPE html>

<html lang="en">

    <head>

        <meta name="viewport" content="width=device-width, initial-scale=1">

        <title>Prime Number Checker in PHP</title>

        <link rel="stylesheet" href="style.css">

    </head>

    <body>

        <main>

            <div class="container">

                <div class="title">

                    <h1>Prime Number Checker in PHP</h1>

                    <h2>&#187; Jake R. Pomperada, MAED-IT, MIT &#171;</h2>

                </div>


                <div class="container-wrapper">

                    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" class="frmChecker">

                        <input type="number" class="txtbox" name="txtNum" id="txtNum" value="<?php echo $input; ?>" placeholder="Input a number" required autofocus>

                        

                        <div class="btnWrapper">

                            <a href="index.php" class="btn btnReset" name="btnReset">Reset</a>

                            <button type="submit" class="btn btnConvert" name="btnConvert">Check</button>

                        </div>


                        <?php echo $out; ?>

                    </form>

                </div>

            </div>

        </main>

    </body>

</html>


Login and Registration in PHP and MySQL

Simple Login and Registration System in PHP and MySQL

 A simple login and registration system in PHP and MySQL that I wrote I hope you will find it useful.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod City I also accepting computer repair, networking, and Arduino Project development at a very affordable price. My website is www.jakerpomperada.blogspot.com and www.jakerpomperada.com

If you like this video please click the LIKE button, SHARE, and SUBSCRIBE to my channel.

Your support on my channel is highly appreciated.

Thank you very much.









Program Listing


php_login.sql

-- phpMyAdmin SQL Dump

-- version 5.0.2

-- https://www.phpmyadmin.net/

--

-- Host: 127.0.0.1

-- Generation Time: Feb 21, 2021 at 01:05 PM

-- Server version: 10.4.14-MariaDB

-- PHP Version: 7.4.9


SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";

START TRANSACTION;

SET time_zone = "+00:00";



/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;

/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;

/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;

/*!40101 SET NAMES utf8mb4 */;


--

-- Database: `php_login`

--


-- --------------------------------------------------------


--

-- Table structure for table `accounts`

--


CREATE TABLE `accounts` (

  `id` int(11) NOT NULL,

  `name` varchar(100) NOT NULL,

  `username` varchar(50) NOT NULL,

  `password` varchar(50) NOT NULL,

  `date_created` datetime NOT NULL DEFAULT current_timestamp()

) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;


--

-- Dumping data for table `accounts`

--


INSERT INTO `accounts` (`id`, `name`, `username`, `password`, `date_created`) VALUES

(2, 'Jake R. Pomperada', 'jakerpomperada', '21232f297a57a5a743894a0e4a801fc3', '2021-02-21 19:45:30');


--

-- Indexes for dumped tables

--


--

-- Indexes for table `accounts`

--

ALTER TABLE `accounts`

  ADD PRIMARY KEY (`id`);


--

-- AUTO_INCREMENT for dumped tables

--


--

-- AUTO_INCREMENT for table `accounts`

--

ALTER TABLE `accounts`

  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;

COMMIT;


/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;

/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;

/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;



style.css

* {
    box-sizing: border-box;
}

body {
    font-family: "Calibri", sans-serif;
    background: #e2e1e0;
    color: #111;
    overflow: auto;
}

main {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.container {
    padding: 50px;
    width: 500px;
    background: #fff;
    text-align: left;
    border-radius: 20px;
    box-shadow: 0 0 60px rgba(0,0,0,0.05);
}

.container.page {
    width: 600px;
}

h1 {
    margin: 0;
    line-height: 1;
}

h3 {
    margin: 3px 0 0;
    font-size: 1.3em;
}

.title {
    display: block;
    text-align: center;
}

.title.page {
    text-transform: capitalize;
}

.name {
    color: #f44336;
}

.txtbox {
    display: block;
    background: #f1f1f1;
    width: 100%;
    margin: 0 0 10px;
    padding: 15px;
    border: none;
    font-size: 20px;
    border-radius: 8px;
    font-family: "Calibri", sans-serif;
    text-align: center;
}

.registration .txtbox {
    text-align: left;
}

.txtbox:first-of-type {
    margin: 30px 0 10px;
}

.txtbox:last-of-type {
    margin: 0;
}

.txtbox:hover,
.txtbox:focus {
    background: #e0e0e0;
}

.btn {
    background: #673ab7;
    color: #fff;
    padding: 15px;
    width: 100%;
    opacity: 0.9;
    outline: none;
    font-size: 20px;
    text-transform: uppercase;
    border: none;
    text-decoration: none;
    text-align: center;
    font-family: "Calibri", sans-serif;
    cursor: pointer;
    text-decoration: none;
    display: block;
    border-radius: 8px;
}

.btn:hover {
    opacity: 1;
}

.btnLogout {
    margin: 0;
}

.btnRegister {
    background: #e91e63;
}

.btnWrapper .btn:first-child {
    margin: 20px 0 10px ;
}

.btnWrapper .btn:last-child {
    margin: 0;
}

.message {
    width: 100%;
    padding: 20px;
    font-size: 18px;
    background: #9e9e9e;
    color: #fff;
    line-height: 1;
    margin-top: 20px;
    border-radius: 8px;
    word-wrap: break-word;
}

index.php

<?php
    $error = "";
    
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
        // Start session
        session_start();

        // Establish connection to the database
        require_once "config.php";

        // Rename and sanitize post data
$user = $con->real_escape_string($_POST['txtUser']);
        $pass = md5($con->real_escape_string($_POST['txtPass']));
        
        // Check if username and password match any record
        if ($stmt = $con->prepare("SELECT `name`, `date_created` FROM `accounts` WHERE `username` = ? AND `password` = ?")) {
            $stmt->bind_param("ss", $user, $pass);
            $stmt->execute();
            $stmt->store_result();

            if($stmt->num_rows > 0) {
                // If there is a match, store account details in session variables, redirect to page.php, and lastly close connection
                $stmt->bind_result($name,$date);
                $stmt->fetch();
                $_SESSION['name'] = $name;
                $_SESSION['date'] = $date;
                $stmt->close();
                header("Location: page.php");
                $con->close();
                exit();
            } else {
                // Show error message if nothing matched
                $error = '<div class="message">You have entered an incorrect Username or Password. Please try again.</div>';
            }
        } else {
            // Show error message incase there is something wrong with the sql statement
            $error = '<div class="message">Prepare failed: ('.$con->errno.') '.$stmt->error.'</div>';
        }
        // Close database connection
        $con->close();
    }
?>
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>Simple Login System in PHP</title>
        <link rel="stylesheet" href="style.css">
    </head>
    <body>
        <main>
            <div class="container">
                <div class="title">
                    <h1>Simple Login System in PHP</h1>
                    <h3>&#187; Jake R. Pomperada, MAED-IT, MIT &#171;</h3>
                </div>

                <div class="container-wrapper login">
                    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
                        <input type="text" class="txtbox" name="txtUser" id="txtUser" placeholder="Username" required>
                        <input type="password" class="txtbox" name="txtPass" id="txtPass" placeholder="Password" required>
                        
                        <div class="btnWrapper">
                            <button type="submit" class="btn btnLogin" name="btnLogin">Login</button>
                            <a href="register.php" class="btn btnRegister" name="btnRegister">Register</a>
                        </div>

                        <?php echo $error; ?>
                    </form>
                </div>
            </div>
        </main>
    </body>
</html>

config.ini

[database]
hostname = localhost
username = root
password = 
dbname = php_login

config.php

<?php
    // Read config.ini file
    $config = parse_ini_file('config.ini'); 

    // Set database connection
    $con = new mysqli($config['hostname'],$config['username'],$config['password'],$config['dbname']);

    // if there is a problem, show error message
    if (mysqli_connect_errno()) {
        printf("Connection failed: %s\n", mysqli_connect_error());
        exit();
    }


logout.php

<?php
    session_start();
    $_SESSION = array();
    session_destroy();
    header("location: index.php");
    exit;
?>

register.php

<?php
    // Start session
    session_start();

    // Declare variables
    $txtName = $txtUser = $name = $user = $msg = $temp = "";

    // Check if logged in (if logged in show back button, if not show login button)
    if (isset($_SESSION["name"])) {
        $button = '<a href="page.php" class="btn btnBack" name="btnBack">Back</a>';
    } else {
        $button = '<a href="index.php" class="btn btnLogin" name="btnLogin">Login</a>';
    }
    
    // Check if form was submitted
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
        // Establish connection to the database
        require_once "config.php";

        // Get and sanitize data
$name = $con->real_escape_string($_POST['txtName']);
$user = $con->real_escape_string($_POST['txtUser']);
        $pass = md5($con->real_escape_string($_POST['txtPass']));
        $conf = md5($con->real_escape_string($_POST['txtConfirm']));
        $checker = 0;
        
        // Check if username is alphanumeric and not less than 4 characters
        if (!ctype_alnum($user) || strlen($user)<4) {
            $checker = 1;
            $temp .= 'Username must be a minimum of 4 alphanumeric characters only.<br><br>';
        }
        
        // Check if password is alphanumeric and not less than 4 characters 
        if (!ctype_alnum($pass) || strlen($pass)<4) {
            $checker = 1;
            $temp .= 'Password must be a minimum of 4 alphanumeric characters only.<br><br>';
        }
        
        // check if password and confirm password matched
        if ($pass != $conf) {
            $checker = 1;
            $temp .= 'Passwords don\'t match.';
        }

        // Check if errors were found
        if($checker == 0) {
            // If there were no errors found, execute insert
            if ($stmt = $con->prepare("INSERT INTO `accounts`(`name`, `username`, `password`) VALUES (?, ?, ?)")) {
                $stmt->bind_param("sss", $name, $user, $pass);
                $stmt->execute();
                $success = "You are successfully registered.";
                $msg = '<div class="message">'.$success.
                                '</div>';
            } else {
                $msg = '<div class="message">Prepare failed: ('.$con->errno.') '.$mysqli->error.'</div>';
            }

        } else {
            // If errors were found, show error message, name, and username
            $txtName = $name;
            $txtUser = $user;
            $msg = '<div class="message">'.$temp.'</div>';
        }

        // Close database connection
        $con->close();
    }
?>
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>Simple Login System in PHP</title>
        <link rel="stylesheet" href="style.css">
    </head>
    <body>
        <main>
            <div class="container registration">
                <div class="title">
                    <h1>Registration Form</h1>
                    <h3>&#187; Jake R. Pomperada, MAED-IT, MIT &#171;</h3>
                </div>

                <div class="container-wrapper">
                    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" class="frmRegister">
                        <input type="text" class="txtbox" name="txtName" id="txtName" value="<?php echo $txtName; ?>" placeholder="Full Name" required>
                        <input type="text" class="txtbox" name="txtUser" id="txtUser" value="<?php echo $txtUser; ?>" placeholder="Username" required>
                        <input type="password" class="txtbox" name="txtPass" id="txtPass" placeholder="Password" required>
                        <input type="password" class="txtbox" name="txtConfirm" id="txtConfirm" placeholder="Confirm Password" required>
                        
                        <div class="btnWrapper">
                            <button type="submit" class="btn btnRegister" name="btnRegister">Register</button>
                            <?php echo $button; ?>
                        </div>
                        

                        <?php echo $msg; ?>
                    </form>
                </div>
            </div>
        </main>
    </body>
</html>


page.php


<?php
    // resume existing session
    session_start();

    // Check if session name exists
    if (!isset($_SESSION["name"])) {
        header("Location: logout.php");
        exit();
    }
?>
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>Simple Login System in PHP</title>
        <link rel="stylesheet" href="style.css">
    </head>
    <body>
        <main>
            <div class="container page">
                <div class="title page">
                    <h1>Welcome <span class="name"><?php echo $_SESSION["name"]; ?></span>!</h1>
                    <h2>Date Created: <?php echo date("F j, Y, g:i A", strtotime($_SESSION["date"]));?></h2>
                    
                    <div class="btnWrapper">
                        <a href="register.php" class="btn btnRegister">Creat New Account</a>
                        <a href="logout.php" class="btn btnLogout">Logout</a>
                    </div>
                </div>
            </div>
        </main>
    </body>
</html>