我正在使用 Wordpress 来构建我的网站。我正在创建一个登录系统,供学校登录到我的系统以查看您的信息。当授权登录的用户遇到问题,他们无法进入授权页面,即查看产品页面。
请帮忙。
下面是登录代码。
session_start();
if($_SERVER["REQUEST_METHOD"] == "POST") {
// School code and password sent from Form
$myschoolcode = ($_POST['schoolcode']);
$mypassword = ($_POST['password']);
$sql = "SELECT school_id FROM schools_info WHERE SchoolCode = '$myschoolcode' and Password = '$mypassword'";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
$active = $row['active'];
$count = mysql_num_rows($result);
// If result matched $myschoolcode and $mypassword, table row must be 1 row
if($count == 1) {
session_register("myschoolcode");
$_SESSION['login_school'] = $myschoolcode;
header("location: ../view-products/");
}
else
{
?>
<script type="text/javascript">
alert("Your School Code or Password is incorrect, please reenter");
history.back();
</script>
<?php
}
}
下面是查看产品页面代码。
session_start();
$school_check = $_SESSION['login_school'];
$ses_sql = mysql_query("SELECT SchoolCode FROM schools_info WHERE SchoolCode = '$school_check' ");
$row = mysql_fetch_array($ses_sql);
$login_session = $row['schoolcode'];
if(!isset($login_session))
{
header("location: ../enter-icas/");
}