Today, We want to share with you jQuery Ajax Secure Login Registration System in PHP and MySQL with validation code free download.In this post we will show you Create a Registration and Login System with PHP and MySQL, hear for Secure Login System with PHP and MySQL we will give you demo and example for implement.In this post, we will learn about student registration form in php code with validation with an example.
jQuery Ajax Secure Login Registration System in PHP and MySQL with validation code free download
There are the Following The simple About Full Information With Example and source code.
As I will cover this Post with live Working example to develop Creating a User Login System with PHP and MySQL, so the some major files and Directory structures for this example is following below.
How to create a Registration and Login System with PHP and MySQL
first of all Here are Main step to read and copy paste your file simple steps you have to follow to make a login system.
JQuery AJAX Login And Registration Form Using PHP MySQLi
- Step: 1Make a Database and Database Table
- Step: 2Connect to the Database
- Step: 3Session Make for Logged in User
- Step: 4Make a Registration and Login Form
- Step: 5Make a Dashboard Page
- Step: 6Make a Logout (Destroy session)
- Step: 7CSS File Make
Step: 1Make a Database and Database Table
CREATE DATABASE memnerSignProject;
CREATE TABLE IF NOT EXISTS `users` ( `id` int(11) NOT NULL AUTO_INCREMENT, `authclient_name` varchar(50) NOT NULL, `email` varchar(50) NOT NULL, `authclient_password` varchar(50) NOT NULL, `member_created_at` datetime NOT NULL, PRIMARY KEY (`id`) );
Step: 2Connect to the Database
databaseconfig.php
<?php $con = mysqli_connect("localhost","root","root","memnerSignProject"); // Check connection if (mysqli_connect_errno()){ echo "Failed to connect to MySQL: " . mysqli_connect_error(); } ?>
Step: 3Session Make for Logged in User
auth_session.php
<?php session_start(); if(!isset($_SESSION["authclient_name"])) { header("Location: signin.php"); exit(); } ?>
Step: 4Make a Registration and Login Form
registration.php
<!DOCTYPE html> <html> <head> <meta charset="utf-8"/> <title>Registration</title> <link rel="stylesheet" href="style.css"/> </head> <body> <?php require('databaseconfig.php'); if (isset($_REQUEST['authclient_name'])) { $authclient_name = stripslashes($_REQUEST['authclient_name']); $authclient_name = mysqli_real_escape_string($con, $authclient_name); $email = stripslashes($_REQUEST['email']); $email = mysqli_real_escape_string($con, $email); $authclient_password = stripslashes($_REQUEST['authclient_password']); $authclient_password = mysqli_real_escape_string($con, $authclient_password); $member_created_at = date("Y-m-d H:i:s"); $query = "INSERT into `users` (authclient_name, authclient_password, email, member_created_at) VALUES ('$authclient_name', '" . md5($authclient_password) . "', '$email', '$member_created_at')"; $result = mysqli_query($con, $query); if ($result) { echo "<div class='form'> <h3>You are registered successfully.</h3><br/> <p class='link'>Click here to <a href='signin.php'>Login</a></p> </div>"; } else { echo "<div class='form'> <h3>Required fields are missing.</h3><br/> <p class='link'>Click here to <a href='registration.php'>registration</a> again.</p> </div>"; } } else { ?> <form class="form" action="" method="post"> <h1 class="login-title">Registration</h1> <input type="text" class="login-input" name="authclient_name" placeholder="Username" required /> <input type="text" class="login-input" name="email" placeholder="Email Adress"> <input type="password" class="login-input" name="authclient_password" placeholder="Password"> <input type="submit" name="submit" value="Register" class="login-button"> <p class="link"><a href="signin.php">Click to Login</a></p> </form> <?php } ?> </body> </html>
Step: 5Make a Dashboard Page
signin.php
<!DOCTYPE html> <html> <head> <meta charset="utf-8"/> <title>Login</title> <link rel="stylesheet" href="style.css"/> </head> <body> <?php require('databaseconfig.php'); session_start(); // When form submitted, check and create client session. if (isset($_POST['authclient_name'])) { $authclient_name = stripslashes($_REQUEST['authclient_name']); // removes backslashes $authclient_name = mysqli_real_escape_string($con, $authclient_name); $authclient_password = stripslashes($_REQUEST['authclient_password']); $authclient_password = mysqli_real_escape_string($con, $authclient_password); // Check client is exist in the database $query = "SELECT * FROM `users` WHERE authclient_name='$authclient_name' AND authclient_password='" . md5($authclient_password) . "'"; $result = mysqli_query($con, $query) or die(mysql_error()); $rows = mysqli_num_rows($result); if ($rows == 1) { $_SESSION['authclient_name'] = $authclient_name; // Redirect to client dashboard page header("Location: dashboard.php"); } else { echo "<div class='form'> <h3>Incorrect Username/authclient_password.</h3><br/> <p class='link'>Click here to <a href='signin.php'>Login</a> again.</p> </div>"; } } else { ?> <form class="form" method="post" name="login"> <h1 class="login-title">Login</h1> <input type="text" class="login-input" name="authclient_name" placeholder="Client Name" autofocus="true"/> <input type="password" class="login-input" name="authclient_password" placeholder="Enter your Secure Password"/> <input type="submit" value="Login" name="submit" class="login-button"/> <p class="link"><a href="registration.php">New Registration</a></p> </form> <?php } ?> </body> </html>
dashboard.php
<?php //include auth_session.php file on all user panel pages include("auth_session.php"); ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Dashboard - Client area</title> <link rel="stylesheet" href="style.css" /> </head> <body> <div class="form"> <p>Welcome To, <?php echo $_SESSION['authclient_name']; ?>!</p> <p>You are now user dashboard page.</p> <p><a href="logout.php">Logout</a></p> </div> </body> </html>
Step: 6Make a Logout (Destroy session)
logout.php
<?php session_start(); // Destroy session if(session_destroy()) { // Redirecting To Home Page header("Location: signin.php"); } ?>
Step: 7CSS File Make
style.php
body { background: #3e4144; } .form { margin: 50px auto; width: 300px; padding: 30px 25px; background: white; } h1.login-title { color: #666; margin: 0px auto 25px; font-size: 25px; font-weight: 300; text-align: center; } .login-input { font-size: 15px; border: 1px solid #ccc; padding: 10px; margin-bottom: 25px; height: 25px; width: calc(100% - 23px); } .login-input:focus { border-color:#6e8095; outline: none; } .login-button { color: #fff; background: #55a1ff; border: 0; outline: 0; width: 100%; height: 50px; font-size: 16px; text-align: center; cursor: pointer; } .link { color: #666; font-size: 15px; text-align: center; margin-bottom: 0px; } .link a { color: #666; } h3 { font-weight: normal; text-align: center; }
Web Programming Tutorials Example with Demo
Read :
Summary
You can also read about AngularJS, ASP.NET, VueJs, PHP.
I hope you get an idea about registration and login form in php and mysql with validation code free download.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.