jQuery+php 登出后无法登入

Berry.C 发布于 2012/04/30 15:31
阅读 448
收藏 0

这code网上找的,之前使用过,没发现有什么问题,但我自行加入jQuery后,发现登出后,无法登入,地址栏会出现logout.php,怎么解决呢?

http://www.9lessons.info/2009/09/php-login-page-example.html

自己修改后:

Config.php

<?php $mysql_hostname = "xx"; $mysql_user = "xx"; $mysql_password = "xx"; $mysql_database = "test"; $bd = mysql_connect($mysql_hostname, $mysql_user, $mysql_password) or die("Opps some thing went wrong"); mysql_select_db($mysql_database, $bd) or die("Opps some thing went wrong"); ?>
index.php
<?php include("config.php"); session_start(); if($_SERVER["REQUEST_METHOD"] == "POST") { // username and password sent from form $myusername=addslashes($_POST['number']); $mypassword=addslashes($_POST['ID']); $sql="SELECT * FROM data WHERE number='$myusername' and ID='$mypassword'"; $result=mysql_query($sql); $row=mysql_fetch_array($result); $active=$row['active']; $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count==1) { session_register("myusername"); $_SESSION['login_user']=$myusername; header("location: welcome.php"); } else { echo'<meta http-equiv=REFRESH CONTENT=1;url=error.html>'; } } ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <title> </title> <link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.css" /> <style> /* App custom styles */ </style> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"> </script> <script src="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.js"> </script> </head> <body> <div data-role="page" id="page1"> <div data-theme="a" data-role="header" data-position="fixed"> <h1> 明愛粉嶺社區進修中心 </h1> <h2> 登入 </h2> </div> <form method="post" autocomplete="on"> <div data-role="content"> <div data-role="fieldcontain"> <fieldset data-role="controlgroup"> <label> 學生證號碼: </label> <input name="number" type="text" required="required" autofocus="autofocus" /> </fieldset> </div> <div data-role="fieldcontain"> <fieldset data-role="controlgroup"> <label> 身份證號碼: </label> <input name="ID" placeholder="首4位組合" type="password" required="required" maxlength="4" /> </fieldset> </div> <div class="ui-grid-a"> <div class="ui-block-a"> <input type="submit" data-icon="check" data-iconpos="left" value="提交" /> </div> <div class="ui-block-b"> <input type="reset" data-icon="delete" data-iconpos="left" value="重設" /> </div> </div> </div> </div> <script> //App custom javascript </script> </body> </html>

lock.php

<?php include('config.php'); session_start(); $user_check=$_SESSION['login_user']; $ses_sql=mysql_query("select * from data where number='$user_check' "); $row=mysql_fetch_array($ses_sql); $login_session=$row['number']; if(!isset($login_session)) { header("Location: index.php"); } ?>
logout.php
<?php session_start(); if(session_destroy()) { header("Location: index.php"); } ?>

welcome.php

<?php include('lock.php'); ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <title> </title> <link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.css" /> <style> /* App custom styles */ </style> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"> </script> <script src="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.js"> </script> </head> <body> <h1>Welcome <?php echo $login_session; ?></h1> <a href="logout.php">Sign Out</a> </body> </html>




 

加载中
0
leo108
leo108
目测没人帮你看代码,太乱
0
李渊
李渊
同学,你提问题的方式要改下。
liao子鱼
liao子鱼
那请问以哪种方式更好?我是真的不知道,虚心求教?
0
jingdor
jingdor
考研眼力的时候来了
0
liao子鱼
liao子鱼
我发现是我的<?php ?>中的php没加,不好意思啊
jeffsui
jeffsui
问题解决了就好,下次注意下发问题的时候,里面含有代码,用代码格式规范下。
返回顶部
顶部