如何修复我的索引页面

时间:2014-01-16 07:01:31

标签: php mysql session home-directory

我是php编程的新手,我尝试为管理员登录编写索引页,但是如果有人告诉我有什么问题以及如何修复它会无法正常工作?

<?php
     session_start();
        if (!isset($_SESSION["manager"])) {
        header("location: admin_login.php"); 
        exit();
    }

    // Be sure to check that this manager SESSION value is in fact in the database
    $managerID = preg_replace('#[^0-9]#i', '', $_SESSION["id"]); // filter everything but numbers and letters

    $manager = preg_replace('#[^A-Za-z0-9]#i', '', $_SESSION["manager"]); // filter everything but numbers and letters

    $password = preg_replace('#[^A-Za-z0-9]#i', '', $_SESSION["password"]); // filter everything but numbers and letters
    // Run mySQL query to be sure that this person is an admin and that their password   session var equals the database information

    // Connect to the MySQL database  
    include "../storescripts/connect_to_mysql.php"; 
    $sql = mysql_query("SELECT * FROM admin WHERE id='$managerID' AND username='$manager' AND password='$password' LIMIT 1"); // query the person

    // ------- MAKE SURE PERSON EXISTS IN DATABASE ---------
     $existCount = mysql_num_rows($sql); // count the row nums
    if ($existCount == 0) { // evaluate the count
         echo "Your login session data is not on record in the database.";
         exit();
    }
    ?> 

1 个答案:

答案 0 :(得分:0)

请提交所有代码,包括html表格,然后我们帮助你。 你想念别人的情况 在其他情况下使用

if ($existCount == 0) { // evaluate the count
         echo "Your login session data is not on record in the database.";
         exit();
    }

else{
$_SESSION["manager"]=$manager;

}