Click here to Skip to main content
15,312,540 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
php (check-login.php)
if (
$_POST['username'] === '1234' &&
$_POST['password'] === '1234' ) {
echo 'correct';
} else {
echo 'wrong';
}

?>


html

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

<head>
   <meta charset="utf-8">
   <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
   
   <title>login</title>
  	<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
    <link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet">
   
  
   <link rel="stylesheet" href="css/bootstrap.css" id="bscss">
 
   <link rel="stylesheet" href="css/app.css" id="maincss">
   
   <style type="text/css">
		.login-form {
			max-width: 300px;
			margin: 0 auto;
			
		}
		#inputUsername {
		  margin-bottom: -1px;
		  border-bottom-right-radius: 0;
		  border-bottom-left-radius: 0;
		}
		#inputPassword {
			border-top-left-radius: 0;
  			border-top-right-radius: 0;
		}
	</style>
	
</head>

 <body ng-app="postExample" ng-controller="PostController as postCtrl">
   <div class="wrapper">
      <div class="block-center mt-xl wd-xl">
    
         <div class="panel panel-dark panel-flat">
            <div class="panel-heading text-center">
               <a href="#">
                  <img src="img/logo.png" alt="Image" class="block-center img-rounded">
               </a>
            </div>
            <div class="panel-body">
               <p class="text-center pv">SIGN IN TO CONTINUE.</p>
              <form class="login-form" ng-submit="postCtrl.postForm()">
		<label for="inputcompanyname" class="sr-only">companyname</label>
		<input type="text" id="inputcompanyname" class="form-control" placeholder="companyname" required autofocus ng-model="postCtrl.inputData.companyname">
        <br>
        <label for="inputUsername" class="sr-only">Username</label>
        <input type="text" id="inputUsername" class="form-control" placeholder="Username" required autofocus ng-model="postCtrl.inputData.username">
        </br>
		<label for="inputPassword" class="sr-only">Password</label>
        <input type="password" id="inputPassword" class="form-control" placeholder="Password" required ng-model="postCtrl.inputData.password">
		<br>
		<div class="alert alert-danger" role="alert" ng-show="errorMsg">{{errorMsg}}</div>
        <button class="btn btn-lg btn-primary btn-block" type="submit">Sign in</button>
		
      </form>
            </div>
			
         </div>
      
         <div class="p-lg text-center">
            <span>VCIDEX @;</span>
            <span>2015</span>
            <span>-</span>
            <span>Bring IT Mass</span>
            <br>
            <span></span>
         </div>
      </div>
   </div>
   
  <script>
	angular.module('postExample', [])
	.controller('PostController', ['$scope', '$http', function($scope, $http) {
		
		this.postForm = function() {
		
			var encodedString = 'username=' +
				encodeURIComponent(this.inputData.username) +
				'&password=' +
				encodeURIComponent(this.inputData.password);
				
			$http({
				method: 'POST',
				url: 'check-login.php',
				data: encodedString,
				headers: {'Content-Type': 'application/x-www-form-urlencoded'}
			})
			.success(function(data, status, headers, config) {
				console.log(data);
				if ( data.trim() === 'correct') {
					window.location.href = 'success.html';
				} else {
					$scope.errorMsg = "Login not correct";
				}
			})
			.error(function(data, status, headers, config) {
				$scope.errorMsg = 'Unable to submit form';
			})
		}
		
	}]);
	</script>
</body>

</html>
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900