In this article, I walk you through the complete process of
creating a user registration system using Frontend(HTML, CSS(Bootstrap) ) and Backend(PHP and MySQL database), where users can create an account by
providing a username, email, and password. After registration, the user can login and logout of her website/store. I will also show you how you can make some pages
accessible only to logged-in users using a session in PHP. Any other user not
logged in will not be able to access the page.
The first thing we'll need to do is set up our
database table under "Ebook_store" we already created in our database.

Now I created a table with different Columns
1. user_id that is auto-increment
2. full name
3. email
4. password
5. memebership_status
6. created_at (it gives the current data and time when the user registers)
Or you can create it on the MySQL prompt using the following SQL script:
NOTE: if you don't need a column, simply remove it and copy the code and paste it under the MySQL database table
And that's it with the database.
Now, create a folder(If you haven't done before) called auth(you can name it as per your requirement or what you like) in a directory accessible to our server. i.e, create the folder inside htdocs (if you are using XAMPP server) or inside www (if you are using WAMPP server).
Open the user_register.php file and paste the following code in it:
<?php include '../views/includes/header.php'; ?>
<div class="container"> <div class="row justify-content-center"> <div class="col-md-6 mt-5 mb-5 rounded p-5 shadow"> <div class="register-container"> <div class="register-header"> <h2 class="text-center font-weight-bold"><i class="bi bi-person-plus"></i> Create Account</h2> </div> <div class="register-body"> <?php if (isset($_GET['error'])): ?> <div class="alert alert-danger" role="alert"> <i class="bi bi-exclamation-triangle"></i> <?php echo htmlspecialchars($_GET['error']); ?> </div> <?php endif; ?> <?php if (isset($_GET['success'])): ?> <div class="alert alert-success" role="alert"> <i class="bi bi-check-circle"></i> <?php echo htmlspecialchars($_GET['success']); ?> </div> <?php endif; ?> <form method="POST" action="../includes/register.php"> <div class="mb-3"> <label for="name" class="form-label">Full Name <span class="text-danger">*</span></label> <input type="text" class="form-control" id="name" name="username" value="" required> </div>
<div class="mb-3"> <label for="email" class="form-label">Email Address <span class="text-danger">*</span></label> <input type="email" class="form-control" id="email" name="email" value="" required> </div>
<div class="mb-3"> <label for="password" class="form-label">Password <span class="text-danger">*</span></label> <input type="password" class="form-control" id="password" name="password" minlength="8" required> <small class="text-muted">Minimum 8 characters</small> </div>
<div class="mb-4"> <label for="confirm_password" class="form-label">Confirm Password <span class="text-danger">*</span></label> <input type="password" class="form-control" id="confirm_password" name="confirm_password" minlength="8" required> </div>
<button type="submit" name="register" class="btn btn-primary w-100 mb-3"> <i class="bi bi-person-plus"></i> Register </button>
<div class="text-center"> <p class="mb-0">Already have an account? <a href="<?php echo BASE_URL; ?>auth/user_login.php" class="text-primary">Login here</a> </p> <a href="<?php echo BASE_URL; ?>index.php" class="text-muted"> <i class="bi bi-arrow-left"></i> Back to Home </a> </div> </form> </div> </div> </div> </div> </div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
<?php include '../views/includes/footer.php'; ?>Hopefully, you’ve done these steps. If yes, you're doing good. If you have done this, you might have noticed one thing: I added two things.Header.php and Footer.php
These are called include files, partials, or template files in web development.
They are reusable components that contain the top (header) and bottom (footer) sections of a website. By including them in multiple pages, you avoid repeating the same code and make your website easier to maintain.
Created these files and put the code below
header.php



