Thursday, 7 January 2021

Build Real time Chat Application in PHP Mysql using WebSocket


In this post, we are going to build a simple PHP and Mysql Chat Application using PHP Web Socket Ratchet. If you are looking for How to create Live or Real time chat Application in PHP then you have come on the right place, because in this post we have share you how to create Live Chat Application PHP with WebSockets. In this post, we will create Chat Application in which multiple user can chat with other users.

This is very interesting post on How to create chat App in PHP without using Ajax. In one of our previous post, we have already published tutorial on Chat application in PHP using ajax. But As we have know in Chat system, Ajax based Chat application in PHP is not best solution, this is because Ajax will increases the load on the server. So for this here we have use Ratchet PHP WebSockets for build real-time live chat application in PHP and in this chat app we will store chat data in Mysql database when one user has post chat under this system.


Build Real time Chat Application in PHP Mysql using WebSocket




What is WebSockets?


WebSockets is a bi-directional and full-duplex which has provide persistent connection from a web browser to our server. So when WebSocket connection has been established in our browser, then it will open connection until client or server has decides to close this connection. So by with this open connection, the user or our server can send or receive chat data at any given time to the each other and it will makes our web programming completely on event driven and not just user started off. The other benefits of this websockets is that, at the same time on single running server, it will connect all connection and it will allowing us to communicate with any number of live connection at the any given time. So this are all benefits of this WebSockets in this Web programming.

Based on this benefits, we have use PHP WebSockets like Ratchet for build Chat Application in PHP and Mysql. Under this post, we will learn you step by step how to build Chat Application in PHP using WebSocket from scratch. Under this PHP Web Development tutorial, you can learn how can we quickly build at Chat App with RatChet using PHP script and Mysql Database.

Database of Chat Application


Before learning chat application, first you need to make tables for store chat application data in Mysql database. So first you need to create tables by run following Sql script you can create chat application tables in you mysql database.


--
-- Database: `chat`
--

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

--
-- Table structure for table `chat_user_table`
--

CREATE TABLE `chat_user_table` (
  `user_id` int(11) NOT NULL,
  `user_name` varchar(250) NOT NULL,
  `user_email` varchar(250) NOT NULL,
  `user_password` varchar(100) NOT NULL,
  `user_profile` varchar(100) NOT NULL,
  `user_status` enum('Disabled','Enable') NOT NULL,
  `user_created_on` datetime NOT NULL,
  `user_verification_code` varchar(100) NOT NULL,
  `user_login_status` enum('Logout','Login') NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `chat_user_table`
--
ALTER TABLE `chat_user_table`
  ADD PRIMARY KEY (`user_id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `chat_user_table`
--
ALTER TABLE `chat_user_table`
  MODIFY `user_id` int(11) NOT NULL AUTO_INCREMENT;


Source Code of PHP Chat Application


Below you can find PHP Chat Application Source code file.

database/Database_connection.php


This file we will use for make database connection under this chat application.


<?php

//Database_connection.php

class Database_connection
{
	function connect()
	{
		$connect = new PDO("mysql:host=localhost; dbname=chat", "root", "");

		return $connect;
	}
}

?>


database/ChatUser.php


This ChatUser.php class file we have use for process user data at server side. Under this class file we have make set and get method for user data and after this we have make method for check user already register or not and lastly we have make insert user data in mysql table.


<?php

//ChatUser.php

class ChatUser
{
	private $user_id;
	private $user_name;
	private $user_email;
	private $user_password;
	private $user_profile;
	private $user_status;
	private $user_created_on;
	private $user_verification_code;
	private $user_login_status;
	public $connect;

	public function __construct()
	{
		require_once('Database_connection.php');

		$database_object = new Database_connection;

		$this->connect = $database_object->connect();
	}

	function setUserId($user_id)
	{
		$this->user_id = $user_id;
	}

	function getUserId()
	{
		return $this->user_id;
	}

	function setUserName($user_name)
	{
		$this->user_name = $user_name;
	}

	function getUserName()
	{
		return $this->user_name;
	}

	function setUserEmail($user_email)
	{
		$this->user_email = $user_email;
	}

	function getUserEmail()
	{
		return $this->user_email;
	}

	function setUserPassword($user_password)
	{
		$this->user_password = $user_password;
	}

	function getUserPassword()
	{
		return $this->user_password;
	}

	function setUserProfile($user_profile)
	{
		$this->user_profile = $user_profile;
	}

	function getUserProfile()
	{
		return $this->user_profile;
	}

	function setUserStatus($user_status)
	{
		$this->user_status = $user_status;
	}

	function getUserStatus()
	{
		return $this->user_status;
	}

	function setUserCreatedOn($user_created_on)
	{
		$this->user_created_on = $user_created_on;
	}

	function getUserCreatedOn()
	{
		return $this->user_created_on;
	}

	function setUserVerificationCode($user_verification_code)
	{
		$this->user_verification_code = $user_verification_code;
	}

	function getUserVerificationCode()
	{
		return $this->user_verification_code;
	}

	function setUserLoginStatus($user_login_status)
	{
		$this->user_login_status = $user_login_status;
	}

	function getUserLoginStatus()
	{
		return $this->user_login_status;
	}

	function make_avatar($character)
	{
	    $path = "images/". time() . ".png";
		$image = imagecreate(200, 200);
		$red = rand(0, 255);
		$green = rand(0, 255);
		$blue = rand(0, 255);
	    imagecolorallocate($image, $red, $green, $blue);  
	    $textcolor = imagecolorallocate($image, 255,255,255);

	    $font = dirname(__FILE__) . '/font/arial.ttf';

	    imagettftext($image, 100, 0, 55, 150, $textcolor, $font, $character);
	    imagepng($image, $path);
	    imagedestroy($image);
	    return $path;
	}

	function get_user_data_by_email()
	{
		$query = "
		SELECT * FROM chat_user_table 
		WHERE user_email = :user_email
		";

		$statement = $this->connect->prepare($query);

		$statement->bindParam(':user_email', $this->user_email);

		if($statement->execute())
		{
			$user_data = $statement->fetch(PDO::FETCH_ASSOC);
		}
		return $user_data;
	}

	function save_data()
	{
		$query = "
		INSERT INTO chat_user_table (user_name, user_email, user_password, user_profile, user_status, user_created_on, user_verification_code) 
		VALUES (:user_name, :user_email, :user_password, :user_profile, :user_status, :user_created_on, :user_verification_code)
		";
		$statement = $this->connect->prepare($query);

		$statement->bindParam(':user_name', $this->user_name);

		$statement->bindParam(':user_email', $this->user_email);

		$statement->bindParam(':user_password', $this->user_password);

		$statement->bindParam(':user_profile', $this->user_profile);

		$statement->bindParam(':user_status', $this->user_status);

		$statement->bindParam(':user_created_on', $this->user_created_on);

		$statement->bindParam(':user_verification_code', $this->user_verification_code);

		if($statement->execute())
		{
			return true;
		}
		else
		{
			return false;
		}
	}

	function is_valid_email_verification_code()
	{
		$query = "
		SELECT * FROM chat_user_table 
		WHERE user_verification_code = :user_verification_code
		";

		$statement = $this->connect->prepare($query);

		$statement->bindParam(':user_verification_code', $this->user_verification_code);

		$statement->execute();

		if($statement->rowCount() > 0)
		{
			return true;
		}
		else
		{
			return false;
		}
	}

	function enable_user_account()
	{
		$query = "
		UPDATE chat_user_table 
		SET user_status = :user_status 
		WHERE user_verification_code = :user_verification_code
		";

		$statement = $this->connect->prepare($query);

		$statement->bindParam(':user_status', $this->user_status);

		$statement->bindParam(':user_verification_code', $this->user_verification_code);

		if($statement->execute())
		{
			return true;
		}
		else
		{
			return false;
		}
	}

	function update_user_login_data()
	{
		$query = "
		UPDATE chat_user_table 
		SET user_login_status = :user_login_status 
		WHERE user_id = :user_id
		";

		$statement = $this->connect->prepare($query);

		$statement->bindParam(':user_login_status', $this->user_login_status);

		$statement->bindParam(':user_id', $this->user_id);

		if($statement->execute())
		{
			return true;
		}
		else
		{
			return false;
		}
	}

}



?>


register.php


This file we have use for get Chat application user registration. User can register from this web page.


<?php

use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;

require 'vendor/autoload.php';

$error = '';

$success_message = '';

if(isset($_POST["register"]))
{
    session_start();

    if(isset($_SESSION['user_data']))
    {
        header('location:chatroom.php');
    }

    require_once('database/ChatUser.php');

    $user_object = new ChatUser;

    $user_object->setUserName($_POST['user_name']);

    $user_object->setUserEmail($_POST['user_email']);

    $user_object->setUserPassword($_POST['user_password']);

    $user_object->setUserProfile($user_object->make_avatar(strtoupper($_POST['user_name'][0])));

    $user_object->setUserStatus('Disabled');

    $user_object->setUserCreatedOn(date('Y-m-d H:i:s'));

    $user_object->setUserVerificationCode(md5(uniqid()));

    $user_data = $user_object->get_user_data_by_email();

    if(is_array($user_data) && count($user_data) > 0)
    {
        $error = 'This Email Already Register';
    }
    else
    {
        if($user_object->save_data())
        {

            $mail = new PHPMailer(true);

            $mail->isSMTP();

            $mail->Host = 'smtpout.secureserver.net';

            $mail->SMTPAuth = true;

            $mail->Username   = 'xxxxx';                     // SMTP username
            $mail->Password   = 'xxxxxx';

            $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;

            $mail->Port = 80;

            $mail->setFrom('tutorial@webslesson.info', 'Webslesson');

            $mail->addAddress($user_object->getUserEmail());

            $mail->isHTML(true);

            $mail->Subject = 'Registration Verification for Chat Application Demo';

            $mail->Body = '
            <p>Thank you for registering for Chat Application Demo.</p>
                <p>This is a verification email, please click the link to verify your email address.</p>
                <p><a href="http://localhost/tutorial/chat_application/verify.php?code='.$user_object->getUserVerificationCode().'">Click to Verify</a></p>
                <p>Thank you...</p>
            ';

            $mail->send();


            $success_message = 'Verification Email sent to ' . $user_object->getUserEmail() . ', so before login first verify your email';
        }
        else
        {
            $error = 'Something went wrong try again';
        }
    }

}


?>

<!DOCTYPE html>
<html lang="en">

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>Register | PHP Chat Application using Websocket</title>

    <!-- Bootstrap core CSS -->
    <link href="vendor-front/bootstrap/bootstrap.min.css" rel="stylesheet">

    <link href="vendor-front/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css">

    <link rel="stylesheet" type="text/css" href="vendor-front/parsley/parsley.css"/>

    <!-- Bootstrap core JavaScript -->
    <script src="vendor-front/jquery/jquery.min.js"></script>
    <script src="vendor-front/bootstrap/js/bootstrap.bundle.min.js"></script>

    <!-- Core plugin JavaScript-->
    <script src="vendor-front/jquery-easing/jquery.easing.min.js"></script>

    <script type="text/javascript" src="vendor-front/parsley/dist/parsley.min.js"></script>
</head>

<body>

    <div class="containter">
        <br />
        <br />
        <h1 class="text-center">Chat Application in PHP & MySql using WebSocket - Email Verification</h1>
        
        <div class="row justify-content-md-center">
            <div class="col col-md-4 mt-5">
                <?php
                if($error != '')
                {
                    echo '
                    <div class="alert alert-warning alert-dismissible fade show" role="alert">
                      '.$error.'
                      <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                      </button>
                    </div>
                    ';
                }

                if($success_message != '')
                {
                    echo '
                    <div class="alert alert-success">
                    '.$success_message.'
                    </div>
                    ';
                }
                ?>
                <div class="card">
                    <div class="card-header">Register</div>
                    <div class="card-body">

                        <form method="post" id="register_form">

                            <div class="form-group">
                                <label>Enter Your Name</label>
                                <input type="text" name="user_name" id="user_name" class="form-control" data-parsley-pattern="/^[a-zA-Z\s]+$/" required />
                            </div>

                            <div class="form-group">
                                <label>Enter Your Email</label>
                                <input type="text" name="user_email" id="user_email" class="form-control" data-parsley-type="email" required />
                            </div>

                            <div class="form-group">
                                <label>Enter Your Password</label>
                                <input type="password" name="user_password" id="user_password" class="form-control" data-parsley-minlength="6" data-parsley-maxlength="12" data-parsley-pattern="^[a-zA-Z]+$" required />
                            </div>

                            <div class="form-group text-center">
                                <input type="submit" name="register" class="btn btn-success" value="Register" />
                            </div>

                        </form>
                        
                    </div>
                </div>
                
            </div>
        </div>
    </div>

</body>

</html>

<script>

$(document).ready(function(){

    $('#register_form').parsley();

});

</script>


index.php


Under this file we will make login page for this chat application.



<?php

session_start();

$error = '';

if(isset($_SESSION['user_data']))
{
    header('location:chatroom.php');
}

if(isset($_POST['login']))
{
    require_once('database/ChatUser.php');

    $user_object = new ChatUser;

    $user_object->setUserEmail($_POST['user_email']);

    $user_data = $user_object->get_user_data_by_email();

    if(is_array($user_data) && count($user_data) > 0)
    {
        if($user_data['user_status'] == 'Enable')
        {
            if($user_data['user_password'] == $_POST['user_password'])
            {
                $user_object->setUserId($user_data['user_id']);
                $user_object->setUserLoginStatus('Login');

                if($user_object->update_user_login_data())
                {
                    $_SESSION['user_data'][$user_data['user_id']] = [
                        'id'    =>  $user_data['user_id'],
                        'name'  =>  $user_data['user_name'],
                        'profile'   =>  $user_data['user_profile']
                    ];

                    header('location:chatroom.php');

                }
            }
            else
            {
                $error = 'Wrong Password';
            }
        }
        else
        {
            $error = 'Please Verify Your Email Address';
        }
    }
    else
    {
        $error = 'Wrong Email Address';
    }
}

?>

<!DOCTYPE html>
<html lang="en">

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>Login | PHP Chat Application using Websocket</title>

    <!-- Bootstrap core CSS -->
    <link href="vendor-front/bootstrap/bootstrap.min.css" rel="stylesheet">

    <link href="vendor-front/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css">

    <link rel="stylesheet" type="text/css" href="vendor-front/parsley/parsley.css"/>

    <!-- Bootstrap core JavaScript -->
    <script src="vendor-front/jquery/jquery.min.js"></script>
    <script src="vendor-front/bootstrap/js/bootstrap.bundle.min.js"></script>

    <!-- Core plugin JavaScript-->
    <script src="vendor-front/jquery-easing/jquery.easing.min.js"></script>

    <script type="text/javascript" src="vendor-front/parsley/dist/parsley.min.js"></script>
</head>

<body>

    <div class="containter">
        <br />
        <br />
        <h1 class="text-center">Chat Application in PHP & MySql using WebSocket - Login</h1>
        <div class="row justify-content-md-center mt-5">
            
            <div class="col-md-4">
               <?php
               if(isset($_SESSION['success_message']))
               {
                    echo '
                    <div class="alert alert-success">
                    '.$_SESSION["success_message"] .'
                    </div>
                    ';
                    unset($_SESSION['success_message']);
               }

               if($error != '')
               {
                    echo '
                    <div class="alert alert-danger">
                    '.$error.'
                    </div>
                    ';
               }
               ?>
                <div class="card">
                    <div class="card-header">Login</div>
                    <div class="card-body">
                        <form method="post" id="login_form">
                            <div class="form-group">
                                <label>Enter Your Email Address</label>
                                <input type="text" name="user_email" id="user_email"  class="form-control" data-parsley-type="email" required />
                            </div>
                            <div class="form-group">
                                <label>Enter Your Password</label>
                                <input type="password" name="user_password" id="user_password" class="form-control" required />
                            </div>
                            <div class="form-group text-center">
                                <input type="submit" name="login" id="login" class="btn btn-primary" value="Login" />
                            </div>
                        </form>
                    </div>  
                </div>
            </div>
        </div>
    </div>

</body>

</html>

<script>

$(document).ready(function(){
    
    $('#login_form').parsley();
    
});

</script>


verify.php


This file source code will verify user email address and it will enable user account for login into chat system.


<?php

//verify.php

$error = '';

session_start();

if(isset($_GET['code']))
{
    require_once('database/ChatUser.php');

    $user_object = new ChatUser;

    $user_object->setUserVerificationCode($_GET['code']);

    if($user_object->is_valid_email_verification_code())
    {
        $user_object->setUserStatus('Enable');

        if($user_object->enable_user_account())
        {
            $_SESSION['success_message'] = 'Your Email Successfully verify, now you can login into this chat Application';

            header('location:index.php');
        }
        else
        {
            $error = 'Something went wrong try again....';
        }
    }
    else
    {
        $error = 'Something went wrong try again....';
    }
}

?>

<!DOCTYPE html>
<html lang="en">

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>Email Verify | PHP Chat Application using Websocket</title>

    <!-- Bootstrap core CSS -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

    <!-- Bootstrap core JavaScript -->
    <script src="https://code.jquery.com/jquery-3.5.1.js" integrity="sha256-QWo7LDvxbWT2tbbQ97B53yJnYU3WhH/C8ycbRAkjPDc=" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>

</head>

<body>

    <div class="containter">
        <br />
        <br />
        <h1 class="text-center">PHP Chat Application using Websocket</h1>
        
        <div class="row justify-content-md-center">
            <div class="col col-md-4 mt-5">
            	<div class="alert alert-danger">
            		<h2><?php echo $error; ?></h2>
            	</div>
            </div>
        </div>
    </div>
</body>

</html>


chatroom.php


This chatroom.php will be only access by login user, so once user has been login into this chat application, then system will redirect page to this chatroom.php file and under this file we will make chat room, so each user can chat with each other.


<?php 

?>

<!DOCTYPE html>
<html>
<head>
	<title>Chat application in php using web scocket programming</title>
	<!-- Bootstrap core CSS -->
    <link href="vendor-front/bootstrap/bootstrap.min.css" rel="stylesheet">

    <link href="vendor-front/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css">

    <link rel="stylesheet" type="text/css" href="vendor-front/parsley/parsley.css"/>

    <!-- Bootstrap core JavaScript -->
    <script src="vendor-front/jquery/jquery.min.js"></script>
    <script src="vendor-front/bootstrap/js/bootstrap.bundle.min.js"></script>

    <!-- Core plugin JavaScript-->
    <script src="vendor-front/jquery-easing/jquery.easing.min.js"></script>

    <script type="text/javascript" src="vendor-front/parsley/dist/parsley.min.js"></script>
	<style type="text/css">
		html,
		body {
		  height: 100%;
		  width: 100%;
		  margin: 0;
		}
		#wrapper
		{
			display: flex;
		  	flex-flow: column;
		  	height: 100%;
		}
		#remaining
		{
			flex-grow : 1;
		}
		#messages {
			height: 200px;
			background: whitesmoke;
			overflow: auto;
		}
		#chat-room-frm {
			margin-top: 10px;
		}
		#user_list
		{
			height:450px;
			overflow-y: auto;
		}

		#messages_area
		{
			height: 650px;
			overflow-y: auto;
			background-color:#e6e6e6;
		}

	</style>
</head>
<body>
	<div class="container">
		<br />
        <h3 class="text-center">Welcome to Chatroom</h3>
        <br />
		<div class="row">
			
			<div class="col-lg-8">
				
			</div>
			<div class="col-lg-4">
				
			</div>
		</div>
	</div>
</body>
<script type="text/javascript">
	
	$(document).ready(function(){
		
		

	});
	
</script>
</html>


This Incomplete post, On every published of this post video tutorial, we will add source code of that video part under this post.





Tuesday, 22 December 2020

Online Student Result Management System in PHP with Mysql


This is PHP and Mysql Project on Online Student Result Management System using PHP and it is web based PHP project and by using this system we can manage Student result online. With this system we not only manage student result but also we can manage exam data, subject data, student data and classes data. The main purpose of developing this Student Result Management System in PHP is to reduce the manual errors and convert result system into computerized system.

An Online Student Result Management System in PHP is a very well organized and appropriate system to utilize. This PHP Student Result Management System is not only for student user but also assist the management which proceed with a large amount of pain to publish the Student results in usual conditions.

This is PHP Project on Student Result Management System, which will helps us to makes the results easily accessible and student can get result wherever they want and by using whichever devices they can check their result because this full responsive which has use Bootstraps 4 library. From this Result Management System, Student can print their result also because student can download result in PDF format also. One of the major advantage of this Student Result Management System is to makes the process extremely convenient for students also. Under this system Student can search their result using valid roll number.

The main impartial of the this PHP project is to supply examination result to the student in a easy way. This PHP project is helpfup for students and institutions for publishing the results in easy way.

Modules of PHP Student Result Management System


Following are the main Module of this Online Student Result Management system.

  1. Login Module - At Admin Side
  2. Classes Management Module - At Admin Side
  3. Student Mangement Module - AT Admin Side
  4. Exam Management Module - At Admin Side
  5. User Management Module - At Admin Side
  6. Profile Management Module - At Admin Side
  7. Result Management Module - At Admin & Student Side

Feature of Student Result Management System


  1. Student can get result by Search Result by entering their roll number.
  2. Student can download Result in PDF format.
  3. This is Multi User System, One Master User and Master user can create number of Subuser.
  4. Master user can see analytics data of total number of result publish, total exam data, total student data, total subject data and total classes data.
  5. Master user can Add Edit and Delete Classes data.
  6. Master user can enable and disable the status of Classes under this System.
  7. Master user can Add New Subject in particular classes and he or she can also edit or remove Subject data also.
  8. Master user can Enable and disable status of Subject of particular class.
  9. Master user can Add, Edit and Delete Student data.
  10. Master user can Enable and Disable the status of student.
  11. Master user can Add, Edit and Delete Exam data.
  12. Master user can Enable and Disable the status of student.
  13. Master user can create new user and he or she can also edit user data also.
  14. Master user can disable the login of sub user and he or she can also enable the login of sub user also.
  15. Master user and Sub User can edit their profile details.
  16. Sub user can add edit and delete result data and Master user can see all user result data in single page.
  17. Sub user and Master user can disable the any student result for publish on internet and they can also enable it also.


Web Technology Used in Online Student Result Management System


There are following Web Technology has used for build this Online Student Result Management System.

At Server-side


  • PHP
  • Mysql Database

At Client-side


  • jQuery
  • Ajax
  • Bootstrap 4
  • Parsley.js
  • jQuery DataTable Plugin
  • Bootstrap Date Picker Plugin

Database Structure of Online Student Result Management System



In this post you can find the complete database for this Online Student Result Management System. So if you want to test this system in your local computer you have to first create database in your local server and then after you have to run following SQL script for make database table for Online Student Result Management System in your local phpMyAdmin. Once you have create table in your database then after you can test this system in your local computer.


--
-- Table structure for table `class_srms`
--

CREATE TABLE `class_srms` (
  `class_id` int(11) NOT NULL,
  `class_name` varchar(250) COLLATE utf8_unicode_ci NOT NULL,
  `class_code` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
  `class_status` enum('Enable','Disable') COLLATE utf8_unicode_ci NOT NULL,
  `class_created_on` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `class_srms`
--

INSERT INTO `class_srms` (`class_id`, `class_name`, `class_code`, `class_status`, `class_created_on`) VALUES
(2, 'BSc 1st Semester Batch 2020', '20f9a4242c75dca66a19499f27fcd4c7', 'Enable', '2020-12-19 18:47:34'),
(3, 'BSc 2nd Semester Batch 2020', '00deb091c5a5d480f7570d7cc1779e48', 'Enable', '2020-12-19 19:02:00'),
(4, 'BSc 3rd Semester Batch 2020', '43ef97482f7b43c9b8e43ab11e85e71e', 'Enable', '2020-12-19 19:04:12'),
(5, 'BSc 4th Semester Batch 2020', 'fea08b0885540a5b95aaf3aa5faf4a22', 'Enable', '2020-12-19 19:04:25'),
(6, 'BSc 5th Semester Batch 2020', '71697242d5e3feaefdc79db4ded5aaf9', 'Enable', '2020-12-19 19:07:58'),
(7, 'BSc 6th Semester Batch 2020', '3e2c8de431577fae5e6be68345a621f8', 'Enable', '2020-12-19 19:08:13'),
(8, 'Computer Science 2020', '1164d9955775def68522e1574bf26345', 'Enable', '2020-12-22 12:25:50');

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

--
-- Table structure for table `exam_srms`
--

CREATE TABLE `exam_srms` (
  `exam_id` int(11) NOT NULL,
  `class_id` int(11) NOT NULL,
  `exam_name` varchar(250) COLLATE utf8_unicode_ci NOT NULL,
  `exam_result_date` date NOT NULL,
  `exam_result_published` enum('No','Yes') COLLATE utf8_unicode_ci NOT NULL,
  `exam_status` enum('Enable','Disabled') COLLATE utf8_unicode_ci NOT NULL,
  `exam_added_on` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `exam_srms`
--

INSERT INTO `exam_srms` (`exam_id`, `class_id`, `exam_name`, `exam_result_date`, `exam_result_published`, `exam_status`, `exam_added_on`) VALUES
(2, 2, 'BSc 1st Semester Exam 2020', '2020-12-22', 'Yes', 'Enable', '2020-12-21 16:32:52'),
(3, 3, 'BSc 2nd Semester Exam 2020', '0000-00-00', 'No', 'Enable', '2020-12-21 16:33:11'),
(4, 4, 'BSc 3rd Semester Exam 2020', '0000-00-00', 'No', 'Enable', '2020-12-21 16:33:27'),
(5, 5, 'BSc 4th Semester Exam 2020', '0000-00-00', 'No', 'Enable', '2020-12-21 16:33:52'),
(6, 6, 'BSc 5th Semester Exam 2020', '0000-00-00', 'No', 'Enable', '2020-12-21 16:34:06'),
(7, 7, 'BSc 6th Semester Exam 2020', '0000-00-00', 'No', 'Enable', '2020-12-21 16:34:20'),
(8, 8, 'Computer Science 2020 Exam', '0000-00-00', 'No', 'Enable', '2020-12-22 12:34:43');

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

--
-- Table structure for table `marks_srms`
--

CREATE TABLE `marks_srms` (
  `marks_id` int(11) NOT NULL,
  `result_id` int(11) NOT NULL,
  `subject_id` int(11) NOT NULL,
  `marks` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `marks_srms`
--

INSERT INTO `marks_srms` (`marks_id`, `result_id`, `subject_id`, `marks`) VALUES
(1, 1, 4, 85),
(2, 1, 5, 56),
(3, 1, 3, 75),
(4, 1, 2, 89),
(5, 2, 6, 63),
(6, 2, 7, 56),
(7, 2, 9, 49),
(8, 2, 8, 59),
(9, 3, 6, 69),
(10, 3, 7, 36),
(11, 3, 9, 79),
(12, 3, 8, 89),
(13, 4, 6, 85),
(14, 4, 7, 75),
(15, 4, 9, 96),
(16, 4, 8, 83),
(17, 5, 6, 96),
(18, 5, 7, 61),
(19, 5, 9, 95),
(20, 5, 8, 99),
(21, 6, 6, 76),
(22, 6, 7, 72),
(23, 6, 9, 85),
(24, 6, 8, 79),
(25, 7, 6, 45),
(26, 7, 7, 59),
(27, 7, 9, 69),
(28, 7, 8, 75),
(29, 8, 6, 69),
(30, 8, 7, 85),
(31, 8, 9, 74),
(32, 8, 8, 56),
(33, 9, 6, 47),
(34, 9, 7, 48),
(35, 9, 9, 49),
(36, 9, 8, 44),
(37, 10, 6, 85),
(38, 10, 7, 74),
(39, 10, 9, 96),
(40, 10, 8, 52),
(41, 11, 6, 69),
(42, 11, 7, 98),
(43, 11, 9, 97),
(44, 11, 8, 99),
(45, 12, 6, 35),
(46, 12, 7, 86),
(47, 12, 9, 98);

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

--
-- Table structure for table `result_srms`
--

CREATE TABLE `result_srms` (
  `result_id` int(11) NOT NULL,
  `class_id` int(11) NOT NULL,
  `student_id` int(11) NOT NULL,
  `exam_id` int(11) NOT NULL,
  `result_percentage` decimal(5,2) NOT NULL,
  `result_status` enum('Enable','Disabled') COLLATE utf8_unicode_ci NOT NULL,
  `result_added_by` varchar(100) COLLATE utf8_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `result_srms`
--

INSERT INTO `result_srms` (`result_id`, `class_id`, `student_id`, `exam_id`, `result_percentage`, `result_status`, `result_added_by`) VALUES
(1, 1, 2, 1, '76.25', 'Enable', 'Master'),
(2, 2, 11, 2, '56.75', 'Enable', 'Peter Parker'),
(3, 2, 8, 2, '68.25', 'Enable', 'Peter Parker'),
(4, 2, 7, 2, '84.75', 'Enable', 'Peter Parker'),
(5, 2, 10, 2, '87.75', 'Enable', 'Peter Parker'),
(6, 2, 5, 2, '78.00', 'Enable', 'Peter Parker'),
(7, 2, 3, 2, '62.00', 'Enable', 'Donna Hubber'),
(8, 2, 6, 2, '71.00', 'Enable', 'Donna Hubber'),
(9, 2, 12, 2, '47.00', 'Enable', 'Donna Hubber'),
(10, 2, 9, 2, '76.75', 'Enable', 'Donna Hubber'),
(11, 2, 4, 2, '90.75', 'Enable', 'Donna Hubber'),
(12, 2, 63, 2, '73.00', 'Enable', 'Peter Parker');

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

--
-- Table structure for table `student_srms`
--

CREATE TABLE `student_srms` (
  `student_id` int(11) NOT NULL,
  `class_id` int(11) NOT NULL,
  `student_name` varchar(250) COLLATE utf8_unicode_ci NOT NULL,
  `student_roll_no` varchar(30) COLLATE utf8_unicode_ci NOT NULL,
  `student_email_id` varchar(150) COLLATE utf8_unicode_ci NOT NULL,
  `student_gender` enum('Male','Female') COLLATE utf8_unicode_ci NOT NULL,
  `student_dob` date NOT NULL,
  `student_status` enum('Enable','Disable') COLLATE utf8_unicode_ci NOT NULL,
  `student_added_by` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
  `student_added_on` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `student_srms`
--

INSERT INTO `student_srms` (`student_id`, `class_id`, `student_name`, `student_roll_no`, `student_email_id`, `student_gender`, `student_dob`, `student_status`, `student_added_by`, `student_added_on`) VALUES
(2, 1, 'Holly Shaw', '2', 'hollyshow@gmail.com', 'Female', '2003-03-12', 'Enable', 'Master', '2020-12-17 10:33:49'),
(3, 2, 'Keara Larson', 'BSC120201', 'oschimmel@loadingya.com', 'Female', '1999-03-28', 'Enable', 'Master', '2020-12-21 11:55:53'),
(4, 2, 'Tara Kuhlman', 'BSC120202', 'gideon.schamber@valueweboffers.com', 'Female', '1998-08-28', 'Enable', 'Master', '2020-12-21 11:57:01'),
(5, 2, 'Jadyn Vandervort', 'BSC120203', 'ephraim97@muqaise.com', 'Female', '2001-02-12', 'Enable', 'Master', '2020-12-21 11:58:01'),
(6, 2, 'Luigi Waters', 'BSC120204', 'hickle.rodger@livescore.cd', 'Male', '2001-05-27', 'Enable', 'Master', '2020-12-21 11:58:43'),
(7, 2, 'Dallin Pfannerstill', 'BSC120205', 'clakin@rmtmarket.ru', 'Female', '2000-08-24', 'Enable', 'Master', '2020-12-21 11:59:28'),
(8, 2, 'Arnaldo Wisozk', 'BSC120206', 'yreinger@clubjeep.es', 'Male', '2001-04-04', 'Enable', 'Master', '2020-12-21 12:00:13'),
(9, 2, 'Sherman Runolfsdottir', 'BSC120207', 'mante.tyler@smileglobal.biz', 'Male', '2001-01-13', 'Enable', 'Master', '2020-12-21 12:00:58'),
(10, 2, 'Demarcus Kovacek', 'BSC120208', 'enrique55@gbtimes.cd', 'Male', '2002-01-22', 'Enable', 'Master', '2020-12-21 12:01:54'),
(11, 2, 'Alexandria Wisoky', 'BSC120209', 'felton94@altynkazyna.kg', 'Female', '2001-10-05', 'Enable', 'Master', '2020-12-21 12:02:33'),
(12, 2, 'Priscilla Spencer', 'BSC1202010', 'eino.kuhlman@mailpluss.com', 'Female', '2001-09-05', 'Enable', 'Master', '2020-12-21 12:03:22'),
(13, 3, 'Cali Witting', 'BSC220201', 'lwilderman@attentv.com', 'Female', '2000-03-04', 'Enable', 'Master', '2020-12-21 12:04:14'),
(14, 3, 'Beverly Gerhold', 'BSC220202', 'keshawn.zulauf@altynkazyna.kg', 'Female', '2000-07-15', 'Enable', 'Master', '2020-12-21 12:05:07'),
(15, 3, 'Dina Rohan', 'BSC220203', 'rosina.bauch@elaseweightloss.com', 'Female', '2000-02-17', 'Enable', 'Master', '2020-12-21 12:05:57'),
(16, 3, 'Laurine Stokes', 'BSC220204', 'yundt.salvador@burgas.vip', 'Female', '2000-11-09', 'Enable', 'Master', '2020-12-21 12:06:39'),
(17, 3, 'Alex Spinka', 'BSC220205', 'millie.konopels@cityxguide.center', 'Male', '2000-05-09', 'Enable', 'Master', '2020-12-21 12:07:25'),
(18, 3, 'Cristina Nicolas', 'BSC220206', 'genoveva.bogan@tyrosine.store', 'Male', '2000-06-28', 'Enable', 'Master', '2020-12-21 12:18:43'),
(19, 3, 'Kaitlin Weber', 'BSC220207', 'raynor.madelyn@dreamstosucceed.com', 'Female', '2000-12-01', 'Enable', 'Master', '2020-12-21 12:19:42'),
(20, 3, 'Brenda Kertzmann', 'BSC220208', 'dcormier@workers.su', 'Female', '2000-10-05', 'Enable', 'Master', '2020-12-21 12:20:19'),
(21, 3, 'Alfonzo Fahey', 'BSC220209', 'ulehner@floorcl.press', 'Male', '2000-09-16', 'Enable', 'Master', '2020-12-21 12:20:57'),
(22, 3, 'Dax Gutmann', 'BSC2202010', 'reagan57@pdfa.site', 'Male', '2000-02-15', 'Enable', 'Master', '2020-12-21 12:22:28'),
(23, 4, 'Favian Kirlin', 'BSC320201', 'antonia.swaniaw@taikz.com', 'Male', '1999-01-15', 'Enable', 'Master', '2020-12-21 12:26:20'),
(24, 4, 'Ernestina Rice', 'BSC320202', 'ghalvorson@voron.center', 'Female', '1999-03-25', 'Enable', 'Master', '2020-12-21 12:27:15'),
(25, 4, 'Brady Tillman', 'BSC320203', 'wjast@322na.com', 'Male', '1999-08-13', 'Enable', 'Master', '2020-12-21 12:27:54'),
(26, 4, 'Lelia Sawayn', 'BSC320204', 'esmeralda39@kocoks.com', 'Female', '1999-10-27', 'Enable', 'Master', '2020-12-21 12:28:31'),
(27, 4, 'Alba Pfeffer', 'BSC320205', 'ward.abdullah@allgreatshop.xyz', 'Female', '1999-12-17', 'Enable', 'Master', '2020-12-21 12:29:18'),
(28, 4, 'Jamal Bednar', 'BSC320206', 'sturner@ikimaru.com', 'Male', '1999-07-15', 'Enable', 'Master', '2020-12-21 12:29:57'),
(29, 4, 'Alfreda Koelpin', 'BSC320207', 'morton.williams@popbum.com', 'Female', '1999-10-26', 'Enable', 'Master', '2020-12-21 12:30:37'),
(30, 4, 'Lyda Dicki', 'BSC320208', 'santiago.kertzm@sparc.support', 'Female', '1999-11-26', 'Enable', 'Master', '2020-12-21 12:31:22'),
(31, 4, 'Aliyah Daugherty', 'BSC320209', 'wgreenholt@davidtbernal.com', 'Female', '2000-01-08', 'Enable', 'Master', '2020-12-21 12:32:04'),
(32, 4, 'Gerry Kunze', 'BSC3202010', 'mekhi81@xmatch.buzz', 'Female', '1999-10-20', 'Enable', 'Master', '2020-12-21 12:32:49'),
(33, 5, 'Bernadine Collins', 'BSC420201', 'maddison39@lagunacottages.vacations', 'Female', '1998-02-03', 'Enable', 'Master', '2020-12-21 12:34:03'),
(34, 5, 'Olaf Herzog', 'BSC420202', 'dcartwright@helpman.ml', 'Male', '1998-07-15', 'Enable', 'Master', '2020-12-21 12:34:45'),
(35, 5, 'Thomas Cummerata', 'BSC420203', 'jensen.goldner@blairdaly.com', 'Male', '1998-06-16', 'Enable', 'Master', '2020-12-21 12:35:28'),
(36, 5, 'Rachael Abernathy', 'BSC420204', 'hfeeney@failmega.ru', 'Female', '1998-08-27', 'Enable', 'Master', '2020-12-21 12:36:14'),
(37, 5, 'Candace Heller', 'BSC420205', 'maritza.reynold@voron.center', 'Female', '1998-11-18', 'Enable', 'Master', '2020-12-21 12:36:55'),
(38, 5, 'Irving Nienow', 'BSC420206', 'hwolf@rzn.services', 'Male', '1998-10-14', 'Enable', 'Master', '2020-12-21 12:37:38'),
(39, 5, 'Queenie Lebsack', 'BSC420207', 'thilll@remarkable.rocks', 'Female', '1998-05-15', 'Enable', 'Master', '2020-12-21 12:38:21'),
(40, 5, 'Cleo Nikolaus', 'BSC420208', 'helen25@kiev.cd', 'Male', '1998-11-19', 'Enable', 'Master', '2020-12-21 16:16:42'),
(41, 5, 'Thelma Friesen', 'BSC420209', 'reynolds.jeffry@gutmorgen.moscow', 'Female', '1998-06-20', 'Enable', 'Master', '2020-12-21 16:17:26'),
(42, 5, 'Dovie Feil', 'BSC4202010', 'hoppe.shanna@mbstoto.biz', 'Female', '1998-08-22', 'Enable', 'Master', '2020-12-21 16:18:12'),
(43, 6, 'Kaia Crist', 'BSC520201', 'pamela.boyer@noveonlaser.com', 'Female', '1997-02-21', 'Enable', 'Master', '2020-12-21 16:18:57'),
(44, 6, 'Gregg West', 'BSC520202', 'garnet99@sdelaemdeputatom.ru', 'Male', '1997-07-19', 'Enable', 'Master', '2020-12-21 16:19:40'),
(45, 6, 'Ara Halvorson', 'BSC520203', 'funk.keith@ericreyess.com', 'Female', '1997-06-17', 'Enable', 'Master', '2020-12-21 16:20:20'),
(46, 6, 'Ethyl Hoeger', 'BSC520204', 'maggio.ahmed@gmailup.com', 'Female', '1997-09-11', 'Enable', 'Master', '2020-12-21 16:21:12'),
(47, 6, 'Mazie Schneider', 'BSC520205', 'kgorczany@hotmail.red', 'Female', '1997-12-03', 'Enable', 'Master', '2020-12-21 16:21:55'),
(48, 6, 'Linnie Hirthe', 'BSC520206', 'gwendolyn47@alaskavalentine.com', 'Female', '1997-08-22', 'Enable', 'Master', '2020-12-21 16:22:34'),
(49, 6, 'Dereck Block', 'BSC520207', 'delbert.quigley@videojuegos.icu', 'Male', '1997-01-09', 'Enable', 'Master', '2020-12-21 16:23:15'),
(50, 6, 'Nelda Ebert', 'BSC520208', 'ed54@cingcawow.guru', 'Female', '1997-08-07', 'Enable', 'Master', '2020-12-21 16:23:54'),
(51, 6, 'Perry Jakubowski', 'BSC520209', 'jrenner@akk.ro', 'Male', '1997-06-07', 'Enable', 'Master', '2020-12-21 16:24:33'),
(52, 6, 'Berta Quitzon', 'BSC5202010', 'ewillms@alaskavalentine.com', 'Male', '1997-10-08', 'Enable', 'Master', '2020-12-21 16:25:16'),
(53, 7, 'Arvilla Boyle', 'BSC620201', 'kathryne.thiel@blogspot.miami', 'Female', '1996-04-18', 'Enable', 'Master', '2020-12-21 16:25:58'),
(54, 7, 'Eva Kuphal', 'BSC620202', 'hagenes.jon@oisg.org', 'Female', '1996-10-15', 'Enable', 'Master', '2020-12-21 16:26:37'),
(55, 7, 'Cordia Hane', 'BSC620203', 'maximus.hand@bahistek58.com', 'Female', '1996-06-13', 'Enable', 'Master', '2020-12-21 16:27:16'),
(56, 7, 'Kariane Auer', 'BSC620204', 'fblanda@ericreyess.com', 'Female', '1996-08-24', 'Enable', 'Master', '2020-12-21 16:28:00'),
(57, 7, 'Octavia Lesch', 'BSC620205', 'bdickens@kurupee.com', 'Female', '1996-07-09', 'Enable', 'Master', '2020-12-21 16:28:38'),
(58, 7, 'Shayna Hane', 'BSC620206', 'nschiller@cent23.com', 'Female', '1996-05-21', 'Enable', 'Master', '2020-12-21 16:29:25'),
(59, 7, 'Lyda Watsica', 'BSC620207', 'hayes.keith@httsmvkcom.pw', 'Female', '1996-11-01', 'Enable', 'Master', '2020-12-21 16:30:03'),
(60, 7, 'Laney Schneider', 'BSC620208', 'zoey58@guidebate.fun', 'Female', '1996-07-18', 'Enable', 'Master', '2020-12-21 16:30:54'),
(61, 7, 'Ashlynn Crooks', 'BSC620209', 'norma.herman@autorace.pt', 'Female', '1996-12-14', 'Enable', 'Master', '2020-12-21 16:31:30'),
(62, 7, 'Shania McCullough', 'BSC6202010', 'block.roscoe@dutchvinyl.com', 'Female', '1996-04-17', 'Enable', 'Master', '2020-12-21 16:32:10'),
(63, 2, 'Sharon Aguiar', 'BSC1202011', 'sharonaguiar@gmail.com', 'Female', '2001-11-28', 'Enable', 'Master', '2020-12-22 12:31:54');

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

--
-- Table structure for table `subject_srms`
--

CREATE TABLE `subject_srms` (
  `subject_id` int(11) NOT NULL,
  `class_id` int(11) NOT NULL,
  `subject_name` varchar(250) COLLATE utf8_unicode_ci NOT NULL,
  `subject_status` enum('Enable','Disable') COLLATE utf8_unicode_ci NOT NULL,
  `subject_created_on` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `subject_srms`
--

INSERT INTO `subject_srms` (`subject_id`, `class_id`, `subject_name`, `subject_status`, `subject_created_on`) VALUES
(2, 1, 'Physics', 'Enable', '2020-12-16 15:44:04'),
(3, 1, 'Maths', 'Enable', '2020-12-16 16:37:33'),
(4, 1, 'Chemistry', 'Enable', '2020-12-17 17:55:16'),
(5, 1, 'English', 'Enable', '2020-12-17 17:55:29'),
(6, 2, 'Chemistry', 'Enable', '2020-12-19 18:48:55'),
(7, 2, 'English', 'Enable', '2020-12-19 18:49:07'),
(8, 2, 'Programming for Problem Solving', 'Disable', '2020-12-19 18:49:32'),
(9, 2, 'Mathematics', 'Enable', '2020-12-19 18:49:56'),
(10, 3, 'Engineering Graphics And Design', 'Enable', '2020-12-19 19:02:30'),
(11, 3, 'Basic Electronics', 'Enable', '2020-12-19 19:02:49'),
(12, 3, 'Physics', 'Enable', '2020-12-19 19:03:04'),
(13, 3, 'Advance Mathematics', 'Enable', '2020-12-19 19:03:18'),
(14, 4, 'Probability Statistics', 'Enable', '2020-12-19 19:05:20'),
(15, 4, 'Database Management System', 'Enable', '2020-12-19 19:05:38'),
(16, 4, 'Data Structures', 'Enable', '2020-12-19 19:05:54'),
(17, 4, 'Digital Fundamental', 'Enable', '2020-12-19 19:06:09'),
(18, 5, 'Operating System', 'Enable', '2020-12-19 19:06:23'),
(19, 5, 'Object Oriented Programming', 'Enable', '2020-12-19 19:06:38'),
(20, 5, 'Computer Organization And Architecture', 'Enable', '2020-12-19 19:07:13'),
(21, 5, 'Discrete Mathematics', 'Enable', '2020-12-19 19:07:35'),
(22, 6, 'Analysis And Design of Algorithms', 'Enable', '2020-12-19 19:08:37'),
(23, 6, 'Computer Networks', 'Enable', '2020-12-19 19:08:51'),
(24, 6, 'Software Engineering', 'Enable', '2020-12-19 19:09:05'),
(25, 6, 'Python for Data Science', 'Enable', '2020-12-19 19:09:21'),
(26, 7, 'Cyber Security', 'Enable', '2020-12-19 19:09:37'),
(27, 7, 'Digital Electronics', 'Enable', '2020-12-19 19:09:53'),
(28, 7, 'Advance DBMS', 'Enable', '2020-12-19 19:10:11'),
(29, 7, 'Computer Graphics', 'Enable', '2020-12-19 19:10:37'),
(30, 8, 'Programming Fundamental', 'Enable', '2020-12-22 12:28:15');

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

--
-- Table structure for table `user_srms`
--

CREATE TABLE `user_srms` (
  `user_id` int(11) NOT NULL,
  `user_name` varchar(250) COLLATE utf8_unicode_ci NOT NULL,
  `user_contact_no` varchar(30) COLLATE utf8_unicode_ci NOT NULL,
  `user_email` varchar(250) COLLATE utf8_unicode_ci NOT NULL,
  `user_password` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
  `user_profile` varchar(150) COLLATE utf8_unicode_ci NOT NULL,
  `user_type` enum('Master','User') COLLATE utf8_unicode_ci NOT NULL,
  `user_status` enum('Enable','Disable') COLLATE utf8_unicode_ci NOT NULL,
  `user_created_on` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `user_srms`
--

INSERT INTO `user_srms` (`user_id`, `user_name`, `user_contact_no`, `user_email`, `user_password`, `user_profile`, `user_type`, `user_status`, `user_created_on`) VALUES
(1, 'John Smith', '85236985520', 'johnsmith@gmail.com', 'password', '../images/21501.jpg', 'Master', 'Enable', '2020-12-15 06:32:20'),
(2, 'Peter Parker', '7412589630', 'peterparker@gmail.com', 'password', '../images/2290.jpg', 'User', 'Enable', '2020-12-15 18:38:35'),
(3, 'Donna Hubber', '7412855563', 'donnahubber@gmail.com', 'password', '../images/386.jpg', 'User', 'Enable', '2020-12-21 11:49:58'),
(4, 'Marie Gagnon', '7539518520', 'mariegagnon@gmail.com', 'password', '../images/1608620890.png', 'User', 'Enable', '2020-12-22 12:38:10');

--
-- Indexes for dumped tables
--

--
-- Indexes for table `class_srms`
--
ALTER TABLE `class_srms`
  ADD PRIMARY KEY (`class_id`);

--
-- Indexes for table `exam_srms`
--
ALTER TABLE `exam_srms`
  ADD PRIMARY KEY (`exam_id`);

--
-- Indexes for table `marks_srms`
--
ALTER TABLE `marks_srms`
  ADD PRIMARY KEY (`marks_id`);

--
-- Indexes for table `result_srms`
--
ALTER TABLE `result_srms`
  ADD PRIMARY KEY (`result_id`);

--
-- Indexes for table `student_srms`
--
ALTER TABLE `student_srms`
  ADD PRIMARY KEY (`student_id`);

--
-- Indexes for table `subject_srms`
--
ALTER TABLE `subject_srms`
  ADD PRIMARY KEY (`subject_id`);

--
-- Indexes for table `user_srms`
--
ALTER TABLE `user_srms`
  ADD PRIMARY KEY (`user_id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `class_srms`
--
ALTER TABLE `class_srms`
  MODIFY `class_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;

--
-- AUTO_INCREMENT for table `exam_srms`
--
ALTER TABLE `exam_srms`
  MODIFY `exam_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;

--
-- AUTO_INCREMENT for table `marks_srms`
--
ALTER TABLE `marks_srms`
  MODIFY `marks_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=48;

--
-- AUTO_INCREMENT for table `result_srms`
--
ALTER TABLE `result_srms`
  MODIFY `result_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=13;

--
-- AUTO_INCREMENT for table `student_srms`
--
ALTER TABLE `student_srms`
  MODIFY `student_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=64;

--
-- AUTO_INCREMENT for table `subject_srms`
--
ALTER TABLE `subject_srms`
  MODIFY `subject_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=31;

--
-- AUTO_INCREMENT for table `user_srms`
--
ALTER TABLE `user_srms`
  MODIFY `user_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;



How to get Source Code of Student Result Management System


Once you have set up database and create tables in that database, now you want to run this Online Student Result Management System in you local computer. So for this you have to download source code of PHP Student Result Management System. For download source code of Student Result Management System first you have to check the online demo of Student Result Management System at admin part. Once you have go to admin part of this Student Result management system you have to login into that system and after login into system you can find souce code download links of this Student Result management system.

If you have any query or inputs regarding this PHP Online Student Result Management System, you can write in comment box, we will reply on your comment. And lastly you can find demo of Online Student Result Mangaement System link below.







Sunday, 6 December 2020

Restaurant Management System in PHP With Source Code


Introduction of Restaurant Management System in PHP


This is PHP Project on Simple "Restaurant Management System", which has been developed in PHP script jQuery and Bootstrap 4 library. The main objective of this system is overcome the problem of current managing table booked and order or billing manual system of the Restaurant, and convert that system into simple and full proofed process by this PHP Restauant Management System. Currently, we have see in restaurant when we have go to restaurant then waiter has come and take order and waiter has write order in diary and then after it will tell order to cooked manually and at the time of creating bill then again waiter go to cashier counter and again tell customer order detail manually, so by using this system Waiter will directly store customer order details and under this system and when customer go to cashier counter his bill with ready with all their food item this.

Goal of Restaurant Management System


This PHP project we have build for educational purpose, so new programmer can learn how to developed any web based application. With this post you will find the complete source code of this system and you can also get the link of Live demo of Restaurant Management System. This Restaurant Management System is an Open Source system which you can download from this post under zip format and you can check complete source code in you local computer. So you can modified code and learn how to build PHP based web application or developed web development application. You can even use the Source code in you academic projects of your final year project.

Modules of Restaurant Management System


Following are the Module of Restaurant Management System.

  1. Order Management Module
  2. Billing Management Module
  3. Live Table Status Module
  4. Food Category Module
  5. Food Item Module
  6. Tax Management Module
  7. User Management Module

Restaurant Management System in PHP With Source Code


Feature of Restaurant Management System


  1. There are mainly three user under this sysem. Master User, Waiter & Cashier
  2. Master User can Set up Restuarant Management System.
  3. Master User can set the Currency of Restuarant Management System at the time of Set of System.
  4. Master User can set the Timezone of this Restuarant Management System at the time of Set of System.
  5. Master User can Add Edit Delete and View Category Data.
  6. Master User can Add Edit Delete and View Food Item Data.
  7. Master User can Add Edit Delete and View tax details.
  8. Master User can Add Edit Delete and View Restaurant Table details.
  9. Master User can Add Edit Delete and View User data. That means master user can create new User account and lock user account also.
  10. Master User can create edit delete and view Restaurant Order data.
  11. Master User can Create Edit Delete and View Restaurant Billing Data.
  12. Master User can View Live Status of Table thatmeans which table is booked and which table is available.
  13. Master User can view data of Today sales, Yesterday sales, Last 7 Days sales and All time sales data also.
  14. Waiter User can Create and edit Order details.
  15. Waiter USer can view Live Table status.
  16. Cashier USer can View list of billing data, he can check the status of bill and he can take print of bill.
  17. Cashier User can view the live table status.
  18. This Restaurant Management System is fully responsive and mobile friendly this is beacuse for build this system we have use Bootstrap 4 Admin template.

Web Technology Used in Restaurant Management System


There are following Web Technology has used for build this Restaurant Management System.

Server-Side


  • PHP
  • Mysql Database

Client-side


  • jQuery
  • Ajax
  • Bootstrap 4
  • Parsley.js
  • jQuery DataTable Plugin
  • Bootstrap Select Plugin


Database of Restaurant Management System


Before start using this Restaurant Management System, first you have to create database of system. So for create database of this system you have to create new database in your local phpmyadmin and then after run following sql script. So it will make required table for this Restaurant Management system and user can check source in your local computer.


--
-- Database: `rms`
--

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

--
-- Table structure for table `order_item_table`
--

CREATE TABLE `order_item_table` (
  `order_item_id` int(11) NOT NULL,
  `order_id` int(11) NOT NULL,
  `product_name` varchar(250) COLLATE utf8_unicode_ci NOT NULL,
  `product_quantity` int(4) NOT NULL,
  `product_rate` decimal(12,2) NOT NULL,
  `product_amount` decimal(12,2) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

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

--
-- Table structure for table `order_table`
--

CREATE TABLE `order_table` (
  `order_id` int(11) NOT NULL,
  `order_number` varchar(30) COLLATE utf8_unicode_ci NOT NULL,
  `order_table` varchar(250) COLLATE utf8_unicode_ci NOT NULL,
  `order_gross_amount` decimal(12,2) NOT NULL,
  `order_tax_amount` decimal(12,2) NOT NULL,
  `order_net_amount` decimal(12,2) NOT NULL,
  `order_date` date NOT NULL,
  `order_time` time NOT NULL,
  `order_waiter` varchar(250) COLLATE utf8_unicode_ci NOT NULL,
  `order_cashier` varchar(250) COLLATE utf8_unicode_ci NOT NULL,
  `order_status` enum('In Process','Completed') COLLATE utf8_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

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

--
-- Table structure for table `order_tax_table`
--

CREATE TABLE `order_tax_table` (
  `order_tax_table_id` int(11) NOT NULL,
  `order_id` int(11) NOT NULL,
  `order_tax_name` varchar(200) COLLATE utf8_unicode_ci NOT NULL,
  `order_tax_percentage` decimal(4,2) NOT NULL,
  `order_tax_amount` decimal(12,2) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

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

--
-- Table structure for table `product_category_table`
--

CREATE TABLE `product_category_table` (
  `category_id` int(11) NOT NULL,
  `category_name` varchar(250) COLLATE utf8_unicode_ci NOT NULL,
  `category_status` enum('Enable','Disable') COLLATE utf8_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

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

--
-- Table structure for table `product_table`
--

CREATE TABLE `product_table` (
  `product_id` int(11) NOT NULL,
  `category_name` varchar(250) COLLATE utf8_unicode_ci NOT NULL,
  `product_name` varchar(250) COLLATE utf8_unicode_ci NOT NULL,
  `product_price` decimal(10,2) NOT NULL,
  `product_status` enum('Enable','Disable') COLLATE utf8_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

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

--
-- Table structure for table `restaurant_table`
--

CREATE TABLE `restaurant_table` (
  `restaurant_id` int(11) NOT NULL,
  `restaurant_name` varchar(250) COLLATE utf8_unicode_ci NOT NULL,
  `restaurant_tag_line` varchar(300) COLLATE utf8_unicode_ci NOT NULL,
  `restaurant_address` text COLLATE utf8_unicode_ci NOT NULL,
  `restaurant_contact_no` varchar(30) COLLATE utf8_unicode_ci NOT NULL,
  `restaurant_email` varchar(250) COLLATE utf8_unicode_ci NOT NULL,
  `restaurant_currency` varchar(10) COLLATE utf8_unicode_ci NOT NULL,
  `restaurant_timezone` varchar(250) COLLATE utf8_unicode_ci NOT NULL,
  `restaurant_logo` varchar(250) COLLATE utf8_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

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

--
-- Table structure for table `table_data`
--

CREATE TABLE `table_data` (
  `table_id` int(11) NOT NULL,
  `table_name` varchar(250) COLLATE utf8_unicode_ci NOT NULL,
  `table_capacity` int(3) NOT NULL,
  `table_status` enum('Enable','Disable') COLLATE utf8_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

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

--
-- Table structure for table `tax_table`
--

CREATE TABLE `tax_table` (
  `tax_id` int(11) NOT NULL,
  `tax_name` varchar(250) COLLATE utf8_unicode_ci NOT NULL,
  `tax_percentage` decimal(4,2) NOT NULL,
  `tax_status` enum('Enable','Disable') COLLATE utf8_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

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

--
-- Table structure for table `user_table`
--

CREATE TABLE `user_table` (
  `user_id` int(11) NOT NULL,
  `user_name` varchar(250) COLLATE utf8_unicode_ci NOT NULL,
  `user_contact_no` varchar(30) COLLATE utf8_unicode_ci NOT NULL,
  `user_email` varchar(30) COLLATE utf8_unicode_ci NOT NULL,
  `user_password` varchar(250) COLLATE utf8_unicode_ci NOT NULL,
  `user_profile` varchar(250) COLLATE utf8_unicode_ci NOT NULL,
  `user_type` enum('Master','Waiter','Cashier') COLLATE utf8_unicode_ci NOT NULL,
  `user_status` enum('Enable','Disable') COLLATE utf8_unicode_ci NOT NULL,
  `user_created_on` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `order_item_table`
--
ALTER TABLE `order_item_table`
  ADD PRIMARY KEY (`order_item_id`);

--
-- Indexes for table `order_table`
--
ALTER TABLE `order_table`
  ADD PRIMARY KEY (`order_id`);

--
-- Indexes for table `order_tax_table`
--
ALTER TABLE `order_tax_table`
  ADD PRIMARY KEY (`order_tax_table_id`);

--
-- Indexes for table `product_category_table`
--
ALTER TABLE `product_category_table`
  ADD PRIMARY KEY (`category_id`);

--
-- Indexes for table `product_table`
--
ALTER TABLE `product_table`
  ADD PRIMARY KEY (`product_id`);

--
-- Indexes for table `restaurant_table`
--
ALTER TABLE `restaurant_table`
  ADD PRIMARY KEY (`restaurant_id`);

--
-- Indexes for table `table_data`
--
ALTER TABLE `table_data`
  ADD PRIMARY KEY (`table_id`);

--
-- Indexes for table `tax_table`
--
ALTER TABLE `tax_table`
  ADD PRIMARY KEY (`tax_id`);

--
-- Indexes for table `user_table`
--
ALTER TABLE `user_table`
  ADD PRIMARY KEY (`user_id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `order_item_table`
--
ALTER TABLE `order_item_table`
  MODIFY `order_item_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1;

--
-- AUTO_INCREMENT for table `order_table`
--
ALTER TABLE `order_table`
  MODIFY `order_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1;

--
-- AUTO_INCREMENT for table `order_tax_table`
--
ALTER TABLE `order_tax_table`
  MODIFY `order_tax_table_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1;

--
-- AUTO_INCREMENT for table `product_category_table`
--
ALTER TABLE `product_category_table`
  MODIFY `category_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1;

--
-- AUTO_INCREMENT for table `product_table`
--
ALTER TABLE `product_table`
  MODIFY `product_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1;

--
-- AUTO_INCREMENT for table `restaurant_table`
--
ALTER TABLE `restaurant_table`
  MODIFY `restaurant_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1;

--
-- AUTO_INCREMENT for table `table_data`
--
ALTER TABLE `table_data`
  MODIFY `table_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1;

--
-- AUTO_INCREMENT for table `tax_table`
--
ALTER TABLE `tax_table`
  MODIFY `tax_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1;

--
-- AUTO_INCREMENT for table `user_table`
--
ALTER TABLE `user_table`
  MODIFY `user_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1;


So before using source code in your local computer first you have to set up database in your local phpmyadmin and then after you can run this PHP Restaurant Management System in your local computer and you can check the whole feature of this Restuarant Management System. But before check this system in your local computer first you have to check the demo of this system. So you can understand the functionality of this system and then after you can check this system in your local computer. With this post you can find demo link of this Restaurant Management System and when you login into demo link Restaurant Management System you can find source code download link. So from demo you can find the complete source code of this Restaurant Management System in PHP.

If you have any query or inputs regarding this PHP Restaurant Management System, you can write in comment box, we will reply on your comment.



Wednesday, 11 November 2020

PHP Project on Visitor Management System using Ajax jQuery Mysql


Don’t you find it difficult to have the record of all the people who have visited your office yesterday? Just forget about yesterday, do you remember the name of the person who was sitting there in your office for 20 minutes for no reason.

The security requirements of large organizations and infrastructure are challenging and growing increasingly. You can’t say with what intention that person was there in your office. Hence, it’s really necessary to install a visitor management system in the working places for security purposes. Wait!!! Don’t say that you don’t know even a bit about the same.

Don’t worry, below we are going to explain the same. Are you ready???

What Is the Visitor Management System?


As the name itself suggests, it's a kind of special technology which tracks the visitors that enter your working place. Let us tell you that these visitors could be anyone like a contractor, interviewee, consultant, client, or maybe the boyfriend of your Personal Assistant. Hence, it can be said that a visitor is the one who is not a full-time employee.

With the help of this system, you will be able to monitor all the people who are entering your building or office.

Visitor Management System allows you to maintain the record of the visitor in order to save time. It has amazing features like one-click digital records, visitor registration, cloud-based, instant notifications, self-check-in, and checks out. And now Register-based entries are not only inefficient, but they’re also vulnerable and there are chances that can be easily stolen or copied.

So for this reason we have made this Visitor Management system in PHP language by using Ajax with jQuery Bootstrap library. By using this web technology, we have build this small PHP project on smart visitor management system. This is completely web based visitor management system, so user can access visitor data from any place and from any devices in which it can access internet.


PHP Project on Visitor Management System using Ajax jQuery Mysql






Web Technology used for build Visitor Management System


Back-end Side


  • PHP
  • Mysql Database

Front-end Side


  • Ajax
  • jQuery
  • Bootstrap 4
  • HTML 5
  • jQuery DataTables Plugin
  • Parsley.js Form Validation Javascript library
  • Bootstrap Datepicker Plugin
  • Font Awesome Icon Library


Database Structure of Visitor Management System


In below SQL script you can find database stucture of Visitor Management System. So you have to just run following script and tables will be make for this Visitor Management System.


--
-- Database: `visitor_managment_system`
--

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

--
-- Table structure for table `admin_table`
--

CREATE TABLE `admin_table` (
  `admin_id` int(11) NOT NULL,
  `admin_name` varchar(250) COLLATE utf8_unicode_ci NOT NULL,
  `admin_contact_no` varchar(30) COLLATE utf8_unicode_ci NOT NULL,
  `admin_email` varchar(250) COLLATE utf8_unicode_ci NOT NULL,
  `admin_password` varchar(200) COLLATE utf8_unicode_ci NOT NULL,
  `admin_profile` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
  `admin_type` enum('Master','User') COLLATE utf8_unicode_ci NOT NULL,
  `admin_created_on` datetime NOT NULL,
  `admin_status` enum('Enable','Disable') COLLATE utf8_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `admin_table`
--

INSERT INTO `admin_table` (`admin_id`, `admin_name`, `admin_contact_no`, `admin_email`, `admin_password`, `admin_profile`, `admin_type`, `admin_created_on`, `admin_status`) VALUES
(1, 'John Smith', '8569874587', 'johnsmith@gmail.com', '$2y$10$SY7Mc5BZsLlTjvNl70xhIOCyIVF9G7Xc1xqMzPmaSYTCrH.LG545q', 'images/22041.jpg', 'Master', '2020-11-06 14:17:27', 'Enable'),
(2, 'Donna Huber', '8523698520', 'donnahuber@gmail.com', '$2y$10$2H2wHdkV8GJrV30TouhkXuTcP1gQeAY1rp7EGM4fYzOf/mibjzEg.', 'images/22308.jpg', 'User', '2020-11-08 09:08:33', 'Enable'),
(3, 'Colin Newton', '7453952852', 'colinnewton@gmail.com', '$2y$10$O.7mlW5/JC5ji5nF5YHDfuTFphnSbpsNN7FaQoG1BHEIEg4TVbLKW', 'images/31598.jpg', 'User', '2020-11-09 12:44:57', 'Enable'),
(4, 'Carl Meza', '9632585203', 'carlmeza@gmail.com', '$2y$10$gyv/CokUtimUAdXlQt9aRO8UBTnjSz.FqQQEk24vfQjgTppkFSz4q', 'images/1604922343.png', 'User', '2020-11-09 12:45:44', 'Enable'),
(5, 'Tyron Stein', '96369852635', 'tyronstein@gmail.com', '$2y$10$WIHtgnX5EqrKuruE31exGeZv.CLIHm52CggX1/vn.vr1d4tceFtsq', 'images/1604922395.png', 'User', '2020-11-09 12:46:35', 'Enable'),
(6, 'Peter Parker', '8569852632', 'peterparker@gmail.com', '$2y$10$uBTtPvR0YLH9f4FZt5uumeDz3HOmO8W2c.sNy8pvm7zvo8LHQ5zh.', 'images/6614.jpg', 'User', '2020-11-11 14:00:27', 'Enable');

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

--
-- Table structure for table `department_table`
--

CREATE TABLE `department_table` (
  `department_id` int(11) NOT NULL,
  `department_name` varchar(250) COLLATE utf8_unicode_ci NOT NULL,
  `department_contact_person` text COLLATE utf8_unicode_ci NOT NULL,
  `department_created_on` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `department_table`
--

INSERT INTO `department_table` (`department_id`, `department_name`, `department_contact_person`, `department_created_on`) VALUES
(3, 'Marketing', 'Leon Batz, Dessie Labadie, Jayda Keebler', '2020-11-07 08:07:09'),
(4, 'HR', 'Peter Parker', '2020-11-07 08:08:47'),
(5, 'Production', 'Aubrey Nelson, Zayan Humphrey, Harris Lowe, Imaan Villa', '2020-11-09 12:41:59'),
(6, 'Accounting', 'Youssef Hook, Yousef Haigh, Marlie Booker', '2020-11-09 12:42:43'),
(7, 'Purchase', 'Harlee Murillo, Helena Lloyd, Kairon Bauer', '2020-11-09 12:43:17');

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

--
-- Table structure for table `visitor_table`
--

CREATE TABLE `visitor_table` (
  `visitor_id` int(11) NOT NULL,
  `visitor_name` varchar(250) COLLATE utf8_unicode_ci NOT NULL,
  `visitor_email` varchar(250) COLLATE utf8_unicode_ci NOT NULL,
  `visitor_mobile_no` int(12) NOT NULL,
  `visitor_address` tinytext COLLATE utf8_unicode_ci NOT NULL,
  `visitor_meet_person_name` varchar(250) COLLATE utf8_unicode_ci NOT NULL,
  `visitor_department` varchar(250) COLLATE utf8_unicode_ci NOT NULL,
  `visitor_reason_to_meet` tinytext COLLATE utf8_unicode_ci NOT NULL,
  `visitor_enter_time` datetime NOT NULL,
  `visitor_outing_remark` tinytext COLLATE utf8_unicode_ci NOT NULL,
  `visitor_out_time` datetime NOT NULL,
  `visitor_status` enum('In','Out') COLLATE utf8_unicode_ci NOT NULL,
  `visitor_enter_by` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `visitor_table`
--

INSERT INTO `visitor_table` (`visitor_id`, `visitor_name`, `visitor_email`, `visitor_mobile_no`, `visitor_address`, `visitor_meet_person_name`, `visitor_department`, `visitor_reason_to_meet`, `visitor_enter_time`, `visitor_outing_remark`, `visitor_out_time`, `visitor_status`, `visitor_enter_by`) VALUES
(1, 'Jenny Titus', 'jennytitus@mailinator.com', 2147483647, '1693 Isaacs Creek Road, Decatur, Illinois - 62522', 'Peter Parker', 'HR', 'For Job Interview', '2020-11-02 13:27:44', 'Inteview Completed', '2020-11-02 13:34:45', 'Out', 5),
(2, 'Mary Washington', 'marywashington@gmail.com', 2147483647, '1308 Hornor Avenue, Bartlesville, 74003 Oklahoma', 'Yousef Haigh', 'Accounting', 'For get pending due check...', '2020-11-09 13:29:28', 'This person leave office, without get his due amount.', '2020-11-09 13:34:30', 'Out', 4),
(3, 'Francisco Moyer', 'franciscomoyer@gmail.com', 2147483647, '1256 Ross Street, Metropolis, 62960 - Illinois', 'Jayda Keebler', 'Marketing', 'For get the sample of product.', '2020-11-09 13:31:11', 'Take product and leave our facility.', '2020-11-09 13:33:47', 'Out', 2),
(4, 'Jennifer Brown', 'jenniferbrown@gmail.com', 2147483647, '3870 Summit Park Avenue, Southfield, 48075 Michigan', 'Peter Parker', 'HR', 'For Job Interview...', '2020-11-09 13:33:13', 'Interview Completed..', '2020-11-09 13:35:02', 'Out', 3),
(5, 'Benny Cochran', 'bennycochran@gmail.com', 2147483647, '1930 Seneca Drive, Portland, 97225 Oregon', 'Harris Lowe', 'Production', 'Deliver inventory item like nuts &amp; bolts.', '2020-11-09 13:36:43', 'After deliver item he leave this place.', '2020-11-09 14:39:04', 'Out', 4),
(6, 'Kristina Johnston', 'kristinajohnson@gmail.com', 2147483647, '2730 Felosa Drive, Brownwood, 76801, Texas', 'Kairon Bauer', 'Purchase', 'Give sample product catalog.', '2020-11-09 13:38:21', 'He received our product cataclog from Mr. Kairon', '2020-11-09 14:37:11', 'Out', 5),
(7, 'William Sherrill', 'williamsherrill@gmail.com', 2147483647, '2852 Alfred Drive, Bayside 11361, New York', 'Peter Parker', 'HR', 'For Job Inteview.', '2020-11-09 13:39:58', 'Leave office after completing his inteview.', '2020-11-09 14:34:47', 'Out', 2),
(8, 'Chuck Stjohn', 'chuckstjohn@gmail.com', 2147483647, '3855 Fincham Road, San Diego 92103, California', 'Aubrey Nelson', 'Production', 'For Repair Machine', '2020-11-09 14:14:56', 'After repair machine of production department, he leave this place.', '2020-11-09 14:39:29', 'Out', 4),
(9, 'Francesca Holland', 'francesca_holland@gmail.com', 2147483647, '3944 Hillhaven Drive, Mira Loma 91752, California', 'Peter Parker', 'HR', 'For Job Interview.', '2020-11-09 14:16:11', 'He completed job interview and leave our place.', '2020-11-09 14:37:29', 'Out', 5),
(10, 'Florence Linn', 'florencelinn@yahoo.com', 2147483647, '2920 Valley Drive, Philadelphia 19146, Pennsylvania', 'Harlee Murillo', 'Purchase', 'For give product quote price.', '2020-11-09 14:17:46', 'He give quote price to Mr. Harlee.', '2020-11-09 14:35:18', 'Out', 2),
(11, 'Christa Castaneda', 'chirsta_castaneda@gmail.com', 2147483647, '3377 Smith Road, Hampton 30228, Georgia', 'Marlie Booker', 'Accounting', 'For get the last stationary bill amount', '2020-11-09 14:19:40', 'He received bill amount and leave office.', '2020-11-09 14:33:15', 'Out', 3),
(12, 'Lisa Tschida', 'lisatschida@mail.com', 2147483647, '986 Bassel Street, Metairie 70001, Louisiana', 'Peter Parker', 'HR', 'For Receptionist Post job interview.', '2020-11-09 14:21:03', 'Interview completed', '2020-11-09 14:33:31', 'Out', 3),
(13, 'Anthony Justice', 'anthony.justice@ymail.com', 2147483647, '964 Pointe Lane, Hollywood 33023, Florida', 'Dessie Labadie', 'Marketing', 'For Received new product sample.', '2020-11-09 14:22:35', 'Ms. Dessie give product sample to Anthony and after this he leave this place.', '2020-11-09 14:40:09', 'Out', 4),
(14, 'William McClure', 'williammcclure@gmail.com', 2147483647, '1411 Elsie Drive, Sergeant Bluff 51054, South Dakota', 'Peter Parker', 'HR', 'For attend Junior Assistance post interview.', '2020-11-09 14:24:11', 'Completed Job Interview.', '2020-11-09 14:37:51', 'Out', 5),
(15, 'Kevin Greene', 'kevingreene@gmail.com', 2147483647, '2786 Armbrester Drive, Rancho Dominguez 90220, California', 'Jayda Keebler', 'Marketing', 'For repair office AC.', '2020-11-09 14:25:33', 'Kevin complete working on repairing of Marketing department AC.', '2020-11-09 14:35:57', 'Out', 2),
(16, 'Misty Pedersen', 'mistypedersen@gmail.com', 2147483647, '4975 Sardis Station, Minneapolis 55402, Minnesota', 'Harlee Murillo', 'Purchase', 'For deliver courier.', '2020-11-09 14:26:59', 'Send courier to Harlee and leave our place.', '2020-11-09 14:34:02', 'Out', 3),
(17, 'Kevin Fenner', 'kevinfenner@gmail.com', 2147483647, '1329 Ray Court, Rockingham 28379, North Carolina', 'Yousef Haigh', 'Accounting', 'Deliver Lunch Tiffin.', '2020-11-09 14:28:19', 'Kevein deliver tiffin to Youset and leave this place.', '2020-11-09 14:40:35', 'Out', 4),
(18, 'Ray McGee', 'raymcgee@gmail.com', 2147483647, '2620 Vineyard Drive, Garfield Heights\r\n 44128, Ohio', 'Youssef Hook', 'Accounting', 'Give us our electricity bill', '2020-11-09 14:29:48', 'Give electricity bill to Youssef of Accounting department and then after leave our place.', '2020-11-09 14:38:32', 'Out', 5),
(19, 'Antonio Krouse', 'antoniokrouse@gmail.com', 2147483647, '414 Hilltop Haven Drive, Rochelle Park 07662, New Jersey', 'Harris Lowe', 'Production', 'For deliver new electrical motor.', '2020-11-09 14:31:22', 'Mr. Harris has received electrical motor from Antonio and and Mr. Antonio leave our office.', '2020-11-09 14:36:40', 'Out', 2),
(20, 'Florence Graham', 'florencegraham@gmail.com', 2147483647, '4441 Patton Lane, Garner 27529, North Carolina', 'Peter Parker', 'HR', 'For Attend receptionist job interview.', '2020-11-09 14:32:47', 'Interview Completed.', '2020-11-09 14:34:18', 'Out', 3),
(21, 'Eliana Martinez', 'elianamartinez@gmail.com', 2147483647, '1137 Nash Street Northbrook, IL 60062', 'Peter Parker', 'HR', 'For Job Interview', '2020-11-11 06:09:55', 'Interview completed and leave our premises.', '2020-11-11 06:19:44', 'Out', 2),
(22, 'Andru Symonds', 'andrusymonds@gmail.com', 2147483647, '1881 Progress Way Cedar Rapids, IA 52401', 'Youssef Hook', 'Accounting', 'Amazon Delivery boy for deliver item of Youssef Hook', '2020-11-11 10:29:29', 'He gave parcel to Youset Hook and leave our facility.', '2020-11-11 10:29:58', 'Out', 3),
(23, 'Adam Smith', 'adamsmith@gmail.com', 2147483647, '964 Pointe Lane, Hollywood 33023, Florida', 'Peter Parker', 'HR', 'For Job Interview.', '2020-11-11 14:24:58', 'Job Interview Completed.', '2020-11-11 14:26:48', 'Out', 6);

--
-- Indexes for dumped tables
--

--
-- Indexes for table `admin_table`
--
ALTER TABLE `admin_table`
  ADD PRIMARY KEY (`admin_id`);

--
-- Indexes for table `department_table`
--
ALTER TABLE `department_table`
  ADD PRIMARY KEY (`department_id`);

--
-- Indexes for table `visitor_table`
--
ALTER TABLE `visitor_table`
  ADD PRIMARY KEY (`visitor_id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `admin_table`
--
ALTER TABLE `admin_table`
  MODIFY `admin_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;

--
-- AUTO_INCREMENT for table `department_table`
--
ALTER TABLE `department_table`
  MODIFY `department_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8;

--
-- AUTO_INCREMENT for table `visitor_table`
--
ALTER TABLE `visitor_table`
  MODIFY `visitor_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=24;


Feature of Visitor Management System


Admin Side


  1. Admin can manage all sub user visitor data.
  2. Admin can complete Visitor Analytics of this System.
  3. Admin can Create new user, edit existing user details and enable or disable sub user login.
  4. Admin can Add New Department with multiple person, edit existing department data and delete department data also.
  5. Admin can Add edit or delete Visitor data.
  6. Admin filter visitor data in date range filter.
  7. Admin can export visitor data in CSV file.
  8. Admin can change his profile details with profile picture.
  9. Admin can change his password.

Sub User Side


  1. Sub User can login into this Visitor Management System.
  2. Sub User can view his visitor entry data, Sub user can add new visitor data or edit and delete existing visitor data.
  3. Sub User can enter outing remarks of his Visitor entry.
  4. Sub User can filter his visitor data in date range filter.
  5. Sub User can export his visitor data in CSV file.
  6. Sub User can manage his profile details like name, email, contact number or even profile image also.
  7. Sub User can change his password details.

So, this are the key feature of this visitor management system, which has been make by using PHP language with Mysql database, jquery, Ajax and Bootstrap 4 library. We will provide source code of Visitor Management System so you can build your own Visitor management system from scratch and you can learn how to build web application project in PHP from scratch.

If you have any query or inputs regarding this Visitor Management System, you can write in comment box, we will reply on your comment.

Tuesday, 10 November 2020

Dynamically Add Item to jQuery Select2 Control using Ajax with PHP



Do you know How to add option in Select2 jQuery plugin using Ajax with PHP language, If you not know then you have come on the right place because in this post you can find How to dynamically add option in Select2 jQuery plugin in PHP script using ajax. Here dynamically add option means that means you can add new option on page without going to another page and that option will be add in select2 jQuery plugin and that option will also store in Mysql database. So when you have filled form second time and at that time then you can also select last added option in select2 jquery plugin. This all process will be dynamically so when you have add new option then that data will be stored in database, so it is called dynamically added option in select2 jQuery plugin.

What is jQuery Select2 plugin?


jQuery Select2 plugin is a jquery plugin which has been used for convert simple select box to advance level select box, and after using Select2 plugin we can do searching feature in Select box, we can load remove data in select box, and it will also provide infinite scrolling of options result also. This Select2 plugin is also compatible with Bootstrap 3 and Bootstrap 4 library also. So we can easily use Select2 plugin with Bootstrap library also.


Which Web Technology used Under this Tutorial


Back-end Side


  1. PHP Script
  2. Mysql Database

Front-end Side


  1. jQuery
  2. Ajax
  3. Bootstrap 4
  4. Select2 jQuery Plugin





Mysql Database


First we have to create category table in our Mysql database. So for this run following SQL script in your mysql database. So it will make category table in your local database.


--
-- Database: `testing`
--

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

--
-- Table structure for table `category`
--

CREATE TABLE `category` (
  `category_id` int(11) NOT NULL,
  `category_name` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `category`
--

INSERT INTO `category` (`category_id`, `category_name`) VALUES
(1, 'Automobile'),
(2, 'Chemicals'),
(5, 'Machinery'),
(6, 'Transport'),
(7, 'Computer'),
(8, 'Food'),
(9, 'Electronics');

--
-- Indexes for dumped tables
--

--
-- Indexes for table `category`
--
ALTER TABLE `category`
  ADD PRIMARY KEY (`category_id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `category`
--
ALTER TABLE `category`
  MODIFY `category_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=10;





In this tutorial we have use above web technology, now we have proceed for how can we dynamically add option to select2 control. So first we have we have to fetch data from category table and then after we have load that data in HTML Select tag. So it it will fill select box with dynamic Mysql data.

Next we want to initialize Select2 plugin, so we have use $('.select2').select2() this method. This method will convert simple select box to advance level selectbox with searching or filtering feature. For add new option, we have to add tags:true option under this select2() method.

After this for add new option, we have use select2:close event. So when we have type something in select box and close that select box then this event occure and at that time we will trigger Ajax request, which will send Ajax request to PHP script for add new option into Mysql category table and on success of Ajax request it will append newly option to Select2 control.

At PHP script, First it will check category already exist in Mysql table or not. If category not exists in table then it will insert new category into Mysql table and that option will be load in select2 select box. So this is complete process of dynamically add option to Select2 jQuery plugin using Ajax with PHP script. Below you can find complete source code of this tutorial.

Source Code


database_connection.php



<?php

//database_connection.php

$connect = new PDO("mysql:host=localhost; dbname=testing", "root", "");

?>


index.php



<?php

//index.php

include('database_connection.php');

$query = "
  SELECT * FROM category 
ORDER BY category_name ASC
";

$result = $connect->query($query);

?>

<!DOCTYPE html>
<html>
  <head>
    <title>Dynamically Add New Option in Select2 using Ajax in PHP</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    	<!-- CSS -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ho+j7jyWK8fNQe+A12Hb8AhRq26LrZ/JpcUGGOn+Y7RsweNrtN/tE3MoK7ZeZDyx" crossorigin="anonymous"></script>
    
    <link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-beta.1/dist/css/select2.min.css" rel="stylesheet" />
    
    <link href="https://raw.githack.com/ttskch/select2-bootstrap4-theme/master/dist/select2-bootstrap4.css" rel="stylesheet" />
    <script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-beta.1/dist/js/select2.min.js"></script>
  </head>
  <body>
  	<div class="container">
  		<br />
  		<br />
    	<h1 align="center">Dynamically Add New Option Tag in Select2 using Ajax in PHP</h1>
    	<br />
    	<br />	
      <div class="row">
        <div class="col-md-6 offset-md-3">
          <select name="category" id="category" class="form-control form-control-lg select2">
            <?php
            foreach($result as $row)
            {
              echo '<option value="'.$row['category_name'].'">'.$row['category_name'].'</option>';
            }
            ?>
          </select>
        </div>
      </div> 
    </div>
  </body>
</html>

<script>

$(document).ready(function(){

  $('.select2').select2({
    placeholder:'Select Category',
    theme:'bootstrap4',
    tags:true,
  }).on('select2:close', function(){
    var element = $(this);
    var new_category = $.trim(element.val());

    if(new_category != '')
    {
      $.ajax({
        url:"add.php",
        method:"POST",
        data:{category_name:new_category},
        success:function(data)
        {
          if(data == 'yes')
          {
            element.append('<option value="'+new_category+'">'+new_category+'</option>').val(new_category);
          }
        }
      })
    }

  });

});

</script>


add.php



<?php

//add.php

include('database_connection.php');

if(isset($_POST["category_name"]))
{
	$category_name = preg_replace('/[^a-zA-Z0-9_ -]/s', '', $_POST["category_name"]);

	$data = array(
		':category_name'	=>	$category_name
	);

	$query = "
	SELECT * FROM category 
	WHERE category_name = :category_name
	";

	$statement = $connect->prepare($query);

	$statement->execute($data);

	if($statement->rowCount() == 0)
	{
		$query = "
		INSERT INTO category 
		(category_name) 
		VALUES (:category_name)
		";

		$statement = $connect->prepare($query);

		$statement->execute($data);

		echo 'yes';
	}
}

?>


Conclusion


In this post we have seen How to dynamically add option to select2 element using Ajax with jQuery and PHP. This feature mainly works if you fill some form and at the time of selection from select box and you want option which has not available in select box then by using this dynamically adding option feature will use for add new option into Select2 element without going to another page.

Lastly, If you have found that this tutorial is helpful to you then do not forget to share this post.