php mysql和登录无法正常工作

时间:2013-05-07 18:30:11

标签: php mysql login

我正在使用php和mysql创建一个登录页面,但在输入电子邮件和密码并提交输入后,浏览器显示一个空白页面而不进入个人资料页面。

如何修复此错误???

的login.php

    <?php
    $message = ""; 
    if(isset($_POST['email'])!="")
    {
    require_once('include/connect.php');
    $email = $_POST['email'];
    $pass = $_POST['pass'];

    $email = strip_tags($email);
    $pass = strip_tags($pass);
    $email = mysql_real_escape_string($email);
    $pass = mysql_real_escape_string($pass);
    //$pass = md5($pass);
    $firstname="";
    $email="";
    $sql=mysql_query( "SELECT user_id FROM user WHERE email_address='$email'AND password='$pass'LIMIT 1") or die("error in user table");
    $login_check = mysql_num_rows($sql);

      if($login_check > 0)
      {
          while($row = mysql_fetch_array($sql))
          {
              $id = $row['user_id'];
              $_SESSION['user_id']= $id;
              var_dump($id);
              $firstname = $row['first_name'];
              $_SESSION['first_name']= $firstname;
              var_dump($firstname);
              $email = $row['email'];
              $_SESSION['email']= $email;
              var_dump($email);
              mysql_query("UPDATE user SET last_log_date=now() WHERE user_id='$id'");

              header("Location: profile.php");    

          }//close while

      }//close if 
      else
      {
          $message = "incorrect Email or Password!!";
          exit();
      }
    }//close if

    ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>RegisterPage</title>

<link href='http://fonts.googleapis.com/css?family=Oswald:400,300' rel='stylesheet' type='text/css' />
<link href='http://fonts.googleapis.com/css?family=Abel|Satisfy' rel='stylesheet' type='text/css' />
<link href="default.css" rel="stylesheet" type="text/css" media="all" />

</head>

<body>


       <div id="loginborder">
         <p  style="color:#FF0000" align="left"><?php print("$message") ?></p>

         <!--Login form where user submit his registered email and password-->
         <form action="login.php" method="post">
           email-address:<br />
           <input type="text" name="email" placeholder="Email Adress" />
           <br />
           <br />
           Password:<br />
           <input type="password" name="pass" placeholder="Password" />
           <br />
           <br />
           <input type="submit" name="login" value="Login" />
           <a href="register.php" style="position: absolute; top: 132px; left: 61px;"> <strong> Register</strong></a>
         </form>
       </div>
       <br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />

      <div id="footer-bg">
    <div id="footer-content" class="container">

        <div id="column3">
            <h2>About Us</h2>
            <ul class="style1">
                <li class="first">Lam El Chamel is the first web development  system for me, this system had allow me to expand my knowledge and had put me in the first step of the programming career.

           Hope that this system will respnd for user's requirements, and as each system it will have a future enhancment with taking into consideration users feedback in the feedback section.
                </li>
          </ul>
        </div>
      <div id="column4">
            <h2>Navigation</h2>
            <ul class="style1">
                <li class="first"><a href="index.php">Home</a></li>
                <li><a href="#">Map</a></li>
                <li><a href="#">Feedback</a></li>
                <li><a href="#">Search</a></li>
                <li><a href="#">Help</a></li>
            </ul>
        </div>
    </div>
</div>
<div id="footer" class="container">
    <p>Copyright (c) 2013 Lam_El_Chamel.zxq.net All rights reserved. Design by Georges Matta.
</div>


</body>
</html>

1 个答案:

答案 0 :(得分:0)

您的登录信息可能会失败

if($login_check > 0)

并执行其他部分

 $message = "incorrect Email or Password!!";
 exit();

$message

之前回复您的exit()变量