0
嘿傢伙我正在創建一個簡單的登錄腳本。當我輸入一個有效的用戶名和密碼時,該函數調用login_success.php,但沒有任何反應。我用以下鏈接的資源:php登錄腳本執行不正確
- http://www.phpeasystep.com/phptu/6.html
- http://forum.codecall.net/topic/44787-creating-loginregistration-forms-with-php/#axzz2DwhIYfzj
- http://frozenade.wordpress.com/2007/11/24/how-to-create-login-page-in-php-and-mysql-with-session/
我還搜查了一些職位上這個網站也是如此。總是感激你的幫助。下面的代碼:
的login.php
<?php
ob_start();
include 'connect.php';
$usernamefield = $_POST['usernamefield'];
$passwordfield = $_POST['passwordfield'];
$sql = "SELECT * FROM login WHERE username = '$usernamefield' and password = '$passwordfield'";
$result = mysql_query($sql);
$count = mysql_num_rows($result);
if($count == 1) {
session_register("usernamefield");
session_register("passwordfield");
header("Location: login_success.php");
} else {
echo "Invalid username or password";
}
exit();
?>
login_success.php
<?php
session_start();
if(!session_is_registered(myusername)){
header("Location: login.php");
}
?>
<html>
<body>
Login Successful
</body>
</html>
非常感謝蒂姆!現在進行更改。 –