get email and password values from mongodb using php

57 views
Skip to first unread message

Bala Kumaran

unread,
Nov 20, 2014, 5:48:07 AM11/20/14
to mongod...@googlegroups.com
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
already i was try code is below



<?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>

s.molinari

unread,
Nov 20, 2014, 10:52:55 AM11/20/14
to mongod...@googlegroups.com
Hello Bala,

I hate to say this in this way, but you need to learn a bit more about programming in PHP. 

But to get you started on learning how to solve the problem, take a look at this.


Scott

Bala Kumar

unread,
Dec 16, 2014, 4:27:53 AM12/16/14
to mongod...@googlegroups.com, bala.a...@gmail.com
Hello molinari.
                          Thanks your replaying. now i use mogodb configure with php for web designing. i will only implement in functionality (Not design). so how can i create config file. otherwise  can i use any php framework like (flat free  framewotk , yamp  yii,  and etc...) . framework necessary or not?  please give me some guidance about mongodb accessing for php. and also how to retrieve values from mongo database to html dropdown list using php. please help me.

                                        Thanking you
Regards
Bala 
Reply all
Reply to author
Forward
0 new messages