Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/289.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
php中成员的配置文件页面_Php_Mongodb - Fatal编程技术网

php中成员的配置文件页面

php中成员的配置文件页面,php,mongodb,Php,Mongodb,这是我的php代码: 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="s

这是我的php代码:

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
    $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");
    } 
    }
    } 
    ?>
registration.php:

<?php 
 session_start();  
 ?>

<!DOCTYPE html>
<html>
    <head>
        <title> Registration </title>
        <meta content="text/html; charset=utf-8" http-equiv="content-type">
        <link href="css/Articles/screen.css" rel="stylesheet">
    </head>
    <body>
        <div id="disposition">
            <div id="header">
                <h1 id="logo">
                    <em align="center"> Registration <em></em>
                </h1>
                <em><span id="slogan"> Registration </span></em>
                <div id="corps">
                    <em></em>
                </div>
            </div>
            <div class="box" id="nav">
                <em></em>
                <ul>
                    <li id="home">
                        <em><a href="Accueil.html">Accueil</a></em>
                    </li>
                    <li>
                        <em><a class="contact" href="contact.html">Contact</a></em>
                    </li>
                </ul>
            </div>
        <div align="center">
        <br>
    </p>

 <form action="registration.php" method="POST">
<b> Pseudo : </b> <br>
<input type="text" id="username" name="username" class="ag" /> <br> <br> 
<b> Email: </b> <br>
<input type="email" id="email" name="email" class="ag" /> <br> <br>
<b> password: </b> <br>
<input type="password" id="password" name="password" class="ag" />  <br> <br> 
<b> Confirm password: </b> <br>
<input type="password" id="c_password" name="confirm_password" class="agrandir" /> <br> <br>
<input  name="submit" id="submit" type="submit" value="Inscription" class="agrandir" /> <br>
</form>
    <br>


  <?php 

if(isset($_POST['submit'])){

    //getting post variable 
    $email=strip_tags($_POST['email']);
    $pass=strip_tags($_POST['password']);
    $confirm_pass=strip_tags($_POST['confirm_password']);
    $username=strip_tags($_POST['username']);

    $error = array();

        if(empty($email) or !filter_var($email,FILTER_SANITIZE_EMAIL))
        {
          $error[] = " <h2> complete email  </h2>";
        }
        if(empty($username)){
          $error[] = " <h2> complet username </h2>";
        }
        if(empty($pass)){
          $error[] = " <h2> complet password </h2> ";
        }
        if(empty($confirm_pass)){
          $error[] = " <h2>confirm password !  </h2> ";
        }
        if($pass != $confirm_pass){
           $error[] = " <h2> password not same !  </h2> ";
        }






        if(count($error) ==0){

            //database configuration
             $host = 'localhost';  
             $database_name = 'projett';
             $database_user_name = '';  
             $database_password = '';  

             //if you have database user name & password then connection may be
             //$connection=new Mongo("mongodb://$database_user_name:$database_password@$dbhost");

             //Currently we are connecting to mongodb without authentication
             $connection=new MongoClient();

             //checking the mongo database connection
             if($connection){

                 //connection à la base de donnée
                 $databse=$connection->$database_name;

                 //connection à la collection reg_user
                 $collection=$databse->reg_users;


                  $query=array('username'=>$username);
                 //checking for existing user
                 $count=$collection->findOne($query);

                 if(!count($count)){

                     //Save the New user
                     $user_data=array('email'=>$email,'password'=>md5($pass),'username'=>$username);             
                     $collection->save($user_data);

                     echo " <h2> succes! </h2> ";


                 }else{
                     echo " <h2> username already use </h2> ";
                 }

             }else{

                  die("  <h2> Database are not connected  </h2>"  );
             }

        }else{
            //Displaying the error
            foreach($error as $err){
                echo $err.'<br />';
            }
        }



}

?>
 <footer>

                <p></p>
                <center>
                    <p>
                        © 2015
                    </p>
                </center>
                <br>

        </footer>
 </body>
 </html>
profil.php

 <?php session_start();?>
 Hello, username

    - your email is : 
我想了解该会员成为会员时的信息:

他填写了登录表 他转到个人资料页 在profil.page中有: 你好,

你的邮件是:我不知道收到他的邮件需要什么密码

我想您需要用户登录的日期和时间。在这种情况下,我将使用: $logdate=日期'd/m/Y'

然后,在每次用户登录时将其添加到数据库中,以帮助跟踪他们持续登录的时间,或者在会话中添加(如果只是在用户访问时使用)

当他们转到个人资料页面时,我也会做与问题1相同的事情

我将创建一个会话,并将用户数据存储在其中,以便您可以在配置文件页面上访问该会话

如果您创建了会话,则可以通过以下方式访问电子邮件地址:

$_SESSION['userinfo']['email']; 

创建会话将使访问数据更容易,因为您不必在每次需要用户信息时都查询数据库。

正如我上面所说,您需要创建一个会话,然后将电子邮件添加到其中并以这种方式访问。我已经给了你所需要的语法。