I have mongo clooection name users .the when users email id and password is vaid. i need login .otherwise display error message . how can i achieve using PHP .please any one help me .advance in thanks
<?php
$succss = "";
if(isset($_POST['submitForm']) && $_POST['submitForm'] == "Login" )
{
// Email Validation
if(empty($email) || !filter_var($email,FILTER_SANITIZE_EMAIL))
{
$error[] = "Empty or invalid email address";
}
if(empty($password)){
$error[] = "Enter your password";
}
if(count($error) == 0){
$con = new Mongo('localhost');
if($con){
// Select Database
$db = $con->maintenance;
// Select Collection
$users = $db->users;
$qry = array("user" => $email,"password" => $password);
$result = $users->findOne($qry);
if($result){
echo "You are successully loggedIn";
$success = "You are successully loggedIn";
// Rest of code up to you....
}
} else {
die("Mongo DB not installed");
echo "fail";
}
}
}
?>
<html>
<head>
<body>
<form action="" method="POST">
Email:
<input type="text" name="email" />
Password:
<input type="password" name="password" />
<input name="submitForm" id="submitForm" type="submit" value="Login" />
</form>
</body>
</head>
</html>