Php Mysql Website Source Code

Login Page in PHP and MySQL with Source Code April 27, 2017 The Largest Hub of Tutorials on Web Designing, Web Development, Programming, Source Codes, Technology, WordPress, SEO, and Blogger. We can develop best web application with minimum source code. PHP Project for students available in PHP. Student can free download php project with source code, PHP projects synopsis and Project report with ease of understanding which help the students to give the primary idea before starting of Project. On our PHP tutorial some projects are given.

If you’re interested in creating Web Services using PHP. Here’s my article on Web Services in PHP. Restful Web Services in PHP Example – PHP + MySQL with Source Code. This Tutorial is designed using Object Oriented PHP. So, you must have a basic knowledge of Object Oriented Concepts in PHP before following this series. Learn to make a simple search engine with PHP, HTML, and a MySQL database. Also learn how to add new entries to the database. FREE source code download! Website against CORONA VIRUS using Bootstrap 4, PHP and MySQL Source Code Let's stay together and fight against coronaVirus. Here is a small contribution from my side, I am creating a dynamic website using PHP and MySQL to spread awareness about Corona Virus and also a solution on how to help others by taking small steps towards the safety of.

Php Mysql Website Source Code Compiler

College Networking Site, developed using PHP and MySQL database, is similar to popular social networking site like Facebook. But, it is not fully social as it is reserved for college students only. With this application, college students can share information between them such as educational materials, their profiles, images, videos, and more.

You can download the complete source code, and necessary project files of this networking project from the link below. Also, available in the download file are project documents: system testing, system design with DFD diagrams, paper presentation, and database design. This project is briefly introduced below, so you can refer the description here as general abstract of this project.

Php mysql website source code download

Download College Networking Site using PHP-MySQL with Source Code


Download College Networking Site using PHP-MySQLwith Source Code and Documents


College Networking Site Project Abstract:

A social networking site restricted to college and the students enrolled there, College Networking Site provides a platform via which students can share information between them. No matter where students are located – in what country or part of the world, with this application college students can get connected for meaningful educational purposed.

In order to use the college networking site, students must be college students and they must create an account. Account creation for other users is restricted. Students can send friend requests to each other, and after that they can send messages, find old friends, share materials and stay connected.


  • It connects students from different countries and part of the world.
  • Students can share and collect knowledge by connecting with each other.
  • Educational materials such as question papers, tutorials, project materials, and presentations can be shared.
  • With this application, students can create their individual profiles and upload images, files, and videos.
  • It provides other social networking features such as email and groups, video sharing, articles, etc.

Inside the Application – System Design:

Dynamic Website Php Mysql Source Code

Php Mysql Website Source Code

Applicable Document:

  1. Profile detail: It manages and stores students’ profile information.
  2. Education detail: It stores education articles, tutorials, questions papers, etc that are shared by students.
  3. Upload detail: It holds images, videos, and any other information uploaded into the application.

Functional Decomposition:

  • Student profile
  • Education profile
  • Education articles
  • Images and videos
  • Quiz, question papers, question-answers, etc.

Functional Components:

Functional Component 1: Student Profile

  • Input – Student adds profile information and education details.
  • Process – System checks previous student account and education details.
  • Output – Student can view education detail and profile details.

Functional Component 2: Tutorials

  • Input – Student uploads education articles, tutorials, images, videos, etc.
  • Process – System uploads education articles, tutorials, images, videos to database.
  • Output – Student can view uploaded education articles, tutorials, images, videos, etc.

Functional Component 3: Admin

  • Input – Admin can upload and share video tutorials, question papers, books, etc.
  • Process – System uploads education tutorials, question papers, books to database.
  • Output – Student can view uploaded tutorials, question papers, books, etc.

Also see,
Chat Room using PHP
Discussion Forum
More PHP Projects


With this college networking website application you can connect with friends, find old friends, share pictures and messages, and reach out to new people registered into the application you’ve never met before. There may be rooms for enhancements and improvements in this project, so students are recommended to work on that to make this application a better one.

For this tutorial I'll be teaching you how you can create your very own secure PHP login system, a login form is what your website's visitors will use to login to your website to access content for logged-in users (such as a profile page).

The Basic and Advanced packages include additional features and a download link to the source code.


  1. Getting Started

1. Getting Started

There are a few steps we need to take before we create our secure login system, we need to set up our web server environment and make sure we have the required extensions enabled.

1.1. Requirements

  • If you haven't got a local web server setup I recommend you download and install XAMPP.
  • XAMPP is a web server package that will run on many operating systems, it includes PHP, MySQL, Apache, phpMyAdmin, and more, no need to install the software separately.

1.2. What You Will Learn in this Tutorial

  • Form Design — Design a login form with HTML5 and CSS3.
  • Prepared SQL Queries — How to prepare SQL queries to prevent SQL injection, this will prevent your database from being exposed.
  • Basic Validation — Validating form data that is sent to the server (username and password).
  • Session Management — Initialize sessions and store retrieved database results.

Php Free Source Code

1.3. File Structure & Setup

We now need to start our web server and create the files and folders we're going to use for our login system.

  • Open XAMPP Control Panel
  • Next to the Apache module click Start
  • Next to the MySQL module click Start
  • Navigate to XAMPPs installation folder (C:xampp)
  • Open the htdocs folder
  • Create the following folders and files:

File Structure

-- phplogin
-- index.html
-- style.css
-- authenticate.php
-- logout.php
-- home.php
-- profile.php

Each file will contain the following:

  • index.html — Login form created with HTML5 and CSS3, we don't need to use PHP in this file so we can just save it as HTML.
  • style.css — The stylesheet (CSS) for our secure login app.
  • authenticate.php — Connect to the database, validate form data, retrieve database results, and create new sessions.
  • logout.php — Destroy the logged in sessions and redirect the user.
  • home.php — Basic home page for logged in users.
  • profile.php — Select the user's account from our MySQL database and display the result.

2. Creating the Login Form Design

We need a login form for our websites users, so they can interact with it and enter their details, we will be using HTML and CSS for this part of the tutorial.

Open up the index.html file with your favorite code editor, we're going to edit this file and add the login form code.

Copy and paste the following code (or create your own layout):

What this will look like if we open it up in our web browser:

Pretty basic right? Let's open up our style.css file and add the following code:


We need to include our stylesheet in our index.html file, copy and paste the following code to the head section:

And now if we reload the index.html file in our web browser our login form will look more appealing:

Let's narrow down the form so we can get a better understanding on what's going on.

  • Form — We need to use both the action and post attributes, the action attribute will be set to the authentication file. When the form is submitted, the form data will be sent to the authentication file for processing. The method is to post, this will allow us to process the form data.
    • Input (text/password) — We need to name our form fields so the server can recognize them, so if we set the value of the attribute name to the username, we can use the post variable in our authentication file to get the data, like this: $_POST['username'].
    • Input (submit) — On click the form data will be sent to our authentication file for processing.

3. Creating the Database and setting-up Tables

For this part, you will need to access your MySQL database, either using phpMyAdmin or your preferred MySQL database management application.

If you're using phpMyAdmin follow these instructions:

  • Navigate to: http://localhost/phpmyadmin/
  • Click the Databases tab at the top
  • Under Create database, type in phplogin in the text box
  • Select utf8_general_ci as the collation
  • Click Create

You can use your own database name, but for this tutorial, we'll use phplogin.

What we need now is an accounts table, this table will store all the accounts (usernames, passwords, emails, etc).

Click the database on the left side panel (phplogin) and execute the following SQL statement:


On phpMyAdmin this should look like:

The above SQL statement code will create the accounts table with the columns id, username, password, and email.

The SQL statement will insert a test account with the username: test, and the password: test, the test account will be used for testing purposes to make sure our login system works correctly.

4. Authenticating Users with PHP

Now that we have our database setup, we can go ahead and start coding with PHP. We're going to start with the authentication, this will handle the form data that we'll send from our index.html file.

Edit the authenticate.php file and add the following:


The first thing we have to do is start the session, this allows us to remember data on the server, this will be used later on to remember logged-in users.

Connecting to the database is essential. Without it, how can we retrieve and store information related to our users? Therefore, we must make sure to update the variables to reflect our MySQL database credentials.

Add below:

This will make sure the form data exists, whereas if the user tries to access the file without submitting the form, it will output a simple error.

Add below:


This will prepare the SQL statement that will select the id and password columns from the accounts table. It will bind the username to the SQL statement, execute, and then store the result.

After this line:


First, we need to check if the query has returned any results. If the username doesn't exist in the database then there would be no results.

If the username exists, we can bind the results to the variables: $id and $password.

Subsequently, we proceed to verify the password with the password_verify function. Only passwords that were created with the password_hash function will work.

If you don't want to use any password encryption method, you can simply replace the following code:



Upon successful authentication from the user, session variables will be initialized and remembered throughout the entire process. These session variables are stored on the server and in the user's browser, we'll use these variables to determine if the user is logged-in or not, and to associate the session variables with our MySQL database.

Now we can test the login system and make sure the authentication works correctly, navigate to http://localhost/phplogin/index.html

Type in a random username and password, and click the login button, it should output an error that should look like the following:

Don't worry, it's not broke! If we go back to our login form and enter test for both the username and password fields the authentication page will look like the following:

If you get an error make sure to double-check your code to make sure you haven't missed anything or check if the test account exists in your database.

5. Creating the Home Page

The home page will be the first page our users see when they've logged-in. The only way they can access this page is if they're logged-in, whereas if they not they will be redirected back to the login page.

Php Mysql Website Source Code Download

Edit the home.php file and add the following code:


Basically, what happens here is we check if the user is logged in, if they are not we redirect them to the homepage, remember the $_SESSION['loggedin'] variable we defined in the authentication.php file? This is what we use to determine if users are logged in or not.

Now we can add some HTML to our home page. Below the closing tag add the following code:

As you can see here all we do is create the layout for our home page and greet the user.

The CSS for the home page, add to style.css:


Now that we have our home page setup we can redirect our users from the authentication.php file, edit authentication.php and replace this line of code:



If you log-in with the test account you should see something like this:

This is a pretty basic home page, you can customize it to how you want now that you understand how it works.

6. Creating the Profile Page

The profile page will display the account information for the logged-in user.

Edit the profile.php file and add the following code:


This demonstrates how you can get additional account information from the database, as before with home page we didn't need to connect to the database because we used the session data.

We're going to display all the account information for the user, so we need to get the password and email fields from the database, we don't need to get the username or id fields because we've them stored in session variables that were created in the authentication.php file.

After the closing tag, add the following code:

A simple layout to display account information, if you navigate to profile.php this will look like:

Remember the passwords are encrypted so you cannot see the decrypted password unless you create a new session variable and store the password from the authentication.php file.

7. Creating the Logout Script

Creating the logout script is very simple, all you need to do is destroy the sessions that we created.

Php source code download

Edit the logout.php file and add the following code:


Initialize sessions and destroy them (if any) and redirect the user to the login page, we use sessions to determine if the user is logged in or not so by removing them the user will not be logged in.


You should now have a basic understanding of how a login system works with PHP and MySQL. You're free to copy the source code and incorporate it into your own projects.

The next step is to create a registration system that will allow visitors to register.

Practical Php And Mysql Website Databases Source Code

Don't forget to follow us and share the article, this will help us create future tutorials.

Next tutorial in this series: Secure Registration System with PHP and MySQL

If you would like to support us consider purchasing a package below, this will greatly help us create more tutorials and keep our server up and running, packages include improved code and more features.


E Commerce Website Php Mysql Source Code Github

Source code
Secure login & registration system
Profile page
Edit profile page
AJAX integration
MVC OOP version

Php Mysql Website Source Codes

Admin Panel
— View Accounts
— Create Accounts
— Edit Accounts
— Email Template
— Settings
Php Mysql Website Source Code
Add-ons (includes instructions)
— Forgot Password
— Brute Force Protection
— CSRF Protection
— Two-factor Authentication
SCSS file
Free updates & support (bugs and minor issues)
* Payments are processed with PayPal/Stripe.
* Advanced package also includes the basic package.



For more detailed information on the advanced package click here.

You have no favorites