mongodb - Profile page for member in php -


this code 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 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 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 have database user name & password connection may              //$connection=new mongo("mongodb://$database_user_name:$database_password@$dbhost");               //currently connecting mongodb without authentication              $connection=new mongoclient();               //checking 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 existing user                  $count=$collection->findone($query);                   if(!count($count)){                       //save new user                      $user_data=array('email'=>$email,'password'=>md5($pass),'username'=>$username);                                   $collection->save($user_data);                       echo " <h2> succes! </h2> ";                    }else{                      echo " <h2> username use </h2> ";                  }               }else{                    die("  <h2> database not connected  </h2>"  );              }          }else{             //displaying error             foreach($error $err){                 echo $err.'<br />';             }         }    }  ?>  <footer>                  <p></p>                 <center>                     <p>                         © 2015                     </p>                 </center>                 <br>          </footer>  </body>  </html> 

profil.php

 <?php session_start();?>  hello, username      - email :  

i want information member when member:

  • he complete login form
  • he go profile page
  • in profil.page there :

hello,

your email : don't know code mail

  1. i'm presuming want date , time of when users logs in. in case use:

$logdate = date('d/m/y');

then add either database every time user logs in track when lasted logged in or in session if being used on users visit.

  1. i same question 1 here when go profile page well.

  2. i create session , store user data in can access session on profile page.

if created session access email address by:

$_session['userinfo']['email'];  

creating session make accessing data easier wouldn't have query database every time needed user information.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -