0

我在登录后无法访问个人资料页面,我还有另一个问题我在不同的数据库中有登录数据,例如电子邮件和密码,并且表名配置文件信息在另一个数据库和表名中如何连接它们以检索配置文件信息如何这些问题得到解决了吗?

这是我的登录 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";

 }

 ?>
4

0 回答 0