- 分享
- 0
- 人气
- 0
- 主题
- 53
- 帖子
- 1781
- UID
- 109880
- 积分
- 795
- 阅读权限
- 17
- 注册时间
- 2007-11-13
- 最后登录
- 2014-1-27
- 在线时间
- 11089 小时
|
index.php
- <html>
- <script>
- @import url(design.css);
- </script>
- <head>
- <title>Scholarship & Bursary - Home</title>
- </head>
- <script language="JavaScript">
- function Login_Validate(theForm)
- {
- if(theForm.userid.value == "")
- {
- alert('Please enter the User ID');
- theForm.id.focus();
- return(false);
- }
- if(theForm.password.value == "")
- {
- alert('Please enter the Password');
- theForm.password.focus();
- return(false);
- }
- }
- </script>
- <body>
- <table align="center">
- <tr>
- <td><img src="banner.jpg" alt="Southern College" width="1000" height="124"></td>
- </tr>
- <tr>
- <td>
- <script>
- var mydate=new Date()
- var year=mydate.getYear()
- if (year < 1000)
- year+=1900
- var day=mydate.getDay()
- var month=mydate.getMonth()
- var daym=mydate.getDate()
- if (daym<10)
- daym="0"+daym
- var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
- var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December")
- document.write("<small><font color='000000' face='Arial'><b>"+dayarray[day]+", "+montharray[month]+" "+daym+", "+year+"</b></font></small>")
- </script>
- <form action="login.php" name="loginForm" id="login" method="post" onsubmit="return Login_Validate(this)">
- <table align="right" style="font-size:0.8em">
- <tr>
- <td>User ID: </td>
- <td colspan="2"><input type="text" name="userid" id="userid" maxlength="11"/></td>
- </tr>
- <tr>
- <td>Password: </td>
- <td colspan="2"><input type="password" name="password" id="password" maxlength="8"/></td>
- </tr>
- <tr>
- <td></td>
- <td><input type="radio" name="lvl" id="student" value="student" checked="checked"/><label for="student">Student</label></td>
- <td><input type="radio" name="lvl" id="staff" value="staff"/><label for="staff">Staff</label></td>
- </tr>
- <tr>
- <td></td>
- <td><input type="submit" name="submit" value="Login"/></td>
- <td><input type="reset" name="submit" value="Clear"/></td>
- </tr>
- </table>
- </form>
- </td>
- </tr>
- <tr>
- <td style="background-color:pink">
- <a href="index.php" title="Home"><span>Home</span></a> |
- <a href="register.php" title="Register"><span>Register</span></a>
- </td>
- <tr>
- <td><hr/></td>
- </tr>
- </table>
- </body>
- </html>
复制代码 login.php
- <?php
- session_start();
- include("connect.php");
- if(isset($_POST["submit"]))
- {
- $id = $_POST["userid"];
- $password = $_POST["password"];
- $lvl = $_POST["lvl"];
-
- if($id != "" && $password != "")
- {
- if($lvl = "staff")
- {
- $result = mysql_query("SELECT * FROM staff_user WHERE userID = '$id' AND password = '$password'");
- if(mysql_num_rows($result) == 1)
- {
- $level = mysql_result($result, '0', 'staffLVL');
- $_SESSION['userlvl'] = $level;
- $_SESSION['userid'] = $id;
- echo "<script>window.location='admin.php'</script>";
- }
- else
- {
- echo "<script>alert('Please check your USER ID and PASSWORD!')</script>";
- echo "<script>window.location='admin.php'</script>";
- }
- }
- else
- {
- $result = mysql_query("SELECT * FROM student_user WHERE userID = '$id' AND password = '$password'");
- if(mysql_num_rows($result) == 1)
- {
- $_SESSION['userlvl'] = "Student";
- $_SESSION['userid'] = $id;
- echo "<script>window.location='applicant.php'</script>";
- }
- else
- {
- echo "<script>alert('Please check your USER ID and PASSWORD!')</script>";
- echo "<script>window.location='index.php'</script>";
- }
- }
- }
- else
- {
- echo "<script>alert('Please check your USER ID and PASSWORD!')</script>";
- echo "<script>window.location='index.php'</script>";
- }
- }
- ?>
复制代码 小弟新手一个...都是自学的...google找了几天都找不到解决方法
就在这一段
- $result = mysql_query("SELECT * FROM staff_user WHERE userID = '$id' AND password = '$password'");
- if(mysql_num_rows($result) == 1)
- {
- $level = mysql_result($result, '0', 'staffLVL');
- $_SESSION['userlvl'] = $level;
- $_SESSION['userid'] = $id;
- echo "<script>window.location='admin.php'</script>";
- }
- else
- {
- echo "<script>alert('Please check your USER ID and PASSWORD!')</script>";
- echo "<script>window.location='index.php'</script>";
- }
复制代码 无论我打的id和password对或错都一定会会进到else里面
出现Please check your USER ID and PASSWORD!这一段
然后会有 window.location='admin.php'"; } else { echo " 的字眼出现在网页里
我在很多情况下都会出现这种字,然后script就不会去别的page了
有人可以教教我吗?谢谢 ~.~ |
|