-3

我是 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();
    }
    ?> 
4

1 回答 1

0

请发布所有代码,包括 html 表单,然后我们帮助你。你错过了 else case 在 else case 使用

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

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

}
于 2014-01-16T07:27:11.993 回答