在php上获取成员的信息

时间:2015-04-28 18:09:52

标签: php mongodb

我有两页:

login.php:

<form action="conn.php" method="POST">
    Username:
    <input type="text" id="username" name="username"  />
    Password:
    <input type="password" id="password" name="password" />    
    <input  name="submit" id="submit" type="submit" value="Login" />
</form>

和PHP

    <?php
    $success = "";
    if(isset($_POST['submit']) == "Login" )   
    {
    $username = strip_tags($_POST['username']);
    $password = strip_tags($_POST['password']);
    $error = array();
    // Username Validation
    if(empty($username))
    {
    $error[] = " Empty or invalid username ";
    }
    if(empty($password)){
    $error[] = "Enter your password"; 
    }
    if(count($error) == 0){
     $host = 'localhost';  
    $database_name = 'projett';
    $database_user_name = '';  
    $database_password = '';  
     $connection=new MongoClient();
      if($connection){
    // Select Database
    $database = $connection->$database_name;

    // Select Collection
    $collection = $database->reg_users;
    $user_data= array("username" => $username,"password" => md5($pass));
    $result = $collection->findOne($user_data);
    if($result){
    $success = "You are successully loggedIn";
    header("Location: Articles.php");
    } 
    } else {
    die("Mongo DB not installed");
    } 
    }
    } 
    ?>

我希望在Member.php上显示该成员的用户名,但是当他完成登录后,用他的用户名打开一个新页面(article.php)

0 个答案:

没有答案