how to access profile after login?

138 views Asked by At

im having trouble accessing profile page after login and I also have another problem I have login data such as email and password in a different database and table name profile information is in another database and table name how can they be connected to retrieve profile information how can these problems be resolved?

here is my login php

 <?php

  include('com.php');

  // Connect to server and select databse.

  mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
  mysql_select_db("$db_name")or die("cannot select DB");


   // username and password sent from form 

  $email=$_POST['email']; 
  $password=$_POST['password']; 

 // To protect MySQL injection (more detail about MySQL injection)

   $email = stripslashes($email);

   $password = stripslashes($password);

   $email = mysql_real_escape_string($email);

   $password = mysql_real_escape_string($password);

   $sql="SELECT * FROM $tbl_name WHERE email='$email' and password='$password'";

   $result=mysql_query($sql);

   // Mysql_num_row is counting table row

   $count=mysql_num_rows($result);

  // If result matched $email and $password, table row must be 1 row

  if($count==1){

   // Register $email, $password and redirect to file "report.php"

   session_register("email");
   session_register("password"); 
   header("location:profile.php");

  }

 else {

   echo "Wrong Username or Password";

 }

 ?>
0

There are 0 answers