检查用户电子邮件和密码

时间:2017-07-04 13:27:22

标签: javascript angularjs angular-ui-router

我想验证表单中的电子邮件和密码是否为真,以便我可以将其重定向到新页面。但是,当我重新加载页面时,它不会验证用户电子邮件和用户密码是否正确,它实际上什么也没做。它只返回了需要检查的用户电子邮件和密码。



 var app = angular
    .module('formValidation', ['ui-router'])
    .controller("locationFormCtrl", locationFormCtrl);
    // .config('$stateprovider','$urlRouterProvider',routeFunc);

    function locationFormCtrl($http,config){
      $http.post(config.apiUrl+ "login", {email: "ehnk@gmail.nl", password: "welkom123"}).then(function(response){
          if(email == "audrey@appsharing.nl" & password == "welkom123"){
            header('Location : opdrachten.html');
          }else{
            alert('wrong password');
          }
      });
    }

<!DOCTYPE html>
	<html>
		<head>
			<title>Login Form</title>
			<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>>
			<script type="text/javascript" src="main.js"></script>
		</head>
		<body ng-app="formValidation" ng-controller="locationFormCtrl" >
		<form novalidate class="simple-form" ng-submit="submit()">
			<label>Email: <input type="text" ng-model="user.email" name="email"/></label><br>
			<label>Password: <input type="password" ng-model="user.password" name="password" required/></label><br>
			<input type="submit"  value="login">
		</form>
		</body>
	</html>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:1)

//please update condition as below..

if(email == "audrey@appsharing.nl" && password == "welkom123"){
   header('Location : opdrachten.html');
}else{
   alert('wrong password');
}