Posted inProgramming / Mysql / Mysqli / php

Vue.js Simple Login Script using PHP MySQLi Bootstrap

Vue.js Simple Login Script using PHP MySQLi Bootstrap

In this Post We Will Explain About is Vue.js Simple Login with PHP/MySQLi With Example and Demo.Welcome on Pakainfo.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to simple login page using Vue.js Example

In this post we will show you Best way to implement simple session with Vue.js and php, hear for Vue.js Login Script using PHP MySQL Bootstrap with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

Creating our Database

CREATE TABLE `usermst` (
  `uID` INT(11) NOT NULL AUTO_INCREMENT,
  `uFirstName` VARCHAR(30) NOT NULL,
  `password` VARCHAR(30) NOT NULL,
PRIMARY KEY(`uID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

Inserting Data into our Database

INSERT INTO `usermst` (`uID`, `uFirstName`, `password`) VALUES
(1, 'jaydeep', 'Gondaliya'),
(2, 'ankit', 'kathiriya');

index.php





	Simple Example of Vue.js Login with PHP and MySQLi
	<link rel="stylesheet" href="


Simple Example of the Vue.js Login with PHP and MySQLi

Log in
{{ msgError }}
{{ msgSuccess }}

main.js

var main = new Vue({
	el: '#login',
	data:{
		msgSuccess: "",
		msgError: "",
		userDetails: {uFirstName: '', password: ''},
	},
 
	methods:{
		allKeyMonitor: function(event) {
       		if(event.key == "Enter"){
         		main.checkLogin();
        	}
       	},
 
		checkLogin: function(){
			var logForm = main.toFormData(main.userDetails);
			axios.post('login.php', logForm)
				.then(function(dataRes){
 
					if(dataRes.data.error){
						main.msgError = dataRes.data.message;
					}
					else{
						main.msgSuccess = dataRes.data.message;
						main.userDetails = {uFirstName: '', password:''};
						setTimeout(function(){
							window.location.href="success.php";
						},2000);
 
					}
				});
		},
 
		toFormData: function(obj){
			var form_data = new FormData();
			for(var key in obj){
				form_data.append(key, obj[key]);
			}
			return form_data;
		},
 
		dataClearMsg: function(){
			main.msgError = '';
			main.msgSuccess = '';
		}
 
	}
});

login.php

connect_error) {
    die("Connection failed: " . $db_con->connect_error);
}
 
$res_Output = array('error' => false);
 
$uFirstName = $_POST['uFirstName'];
$password = $_POST['password'];
 
if($uFirstName==''){
	$res_Output['error'] = true;
	$res_Output['message'] = "UserFirstName is required";
}
else if($password==''){
	$res_Output['error'] = true;
	$res_Output['message'] = "Your Password is required";
}
else{
	$sql = "select * from usermst where uFirstName='$uFirstName' and password='$password'";
	$query = $db_con->query($sql);
 
	if($query->num_rows>0){
		$row=$query->fetch_array();
		$_SESSION['usermst']=$row['uID'];
		$res_Output['message'] = "Login Successful";
	}
	else{
		$res_Output['error'] = true;
		$res_Output['message'] = "User Login Failed. User not Found";
	}
}
 
 
 
$db_con->close();
 
header("Content-type: application/json");
echo json_encode($res_Output);
die();
 
 
?>

success.php

connect_error) {
	    die("Connection failed: " . $db_con->connect_error);
	}
 
	if (!isset($_SESSION['usermst']) ||(trim ($_SESSION['usermst']) == '')){
		header('location:index.php');
	}
 
	$sql="select * from usermst where uID='".$_SESSION['usermst']."'";
	$query=$db_con->query($sql);
	$row=$query->fetch_array();
 
?>



	Example of the Vue.js Login with PHP as well as MySQLi demo
	<link rel="stylesheet" href="


	


logout.php


You are Most welcome in my youtube Channel Please subscribe my channel. and give me FeedBack.
More Details……
Angularjs Example

Example

I hope you have Got What is Vue.js Simple Login with PHP/MySQLi And how it works.I would Like to have FeedBack From My Blog(Pakainfo.com) readers.Your Valuable FeedBack,Any Question,or any Comments about This Article(Pakainfo.com) Are Most Always Welcome.

I am Jaydeep Gondaliya , a software engineer, the founder and the person running Pakainfo. I'm a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, JavaScript, jQuery, Laravel, CodeIgniter, VueJS, AngularJS and Bootstrap from the early stage.

Leave a Reply

Your email address will not be published. Required fields are marked *

We accept paid guest Posting on our Site : Guest Post Chat with Us On Skype