<?php
session_start();
ob_start();
echo "0LIV3R 's first game";
require("DatabaseObject.php");
require("databaseVars.php");
$database= new DatabaseObject($host, $username, $password, $database);
if(!isset($_SESSION['user_id']) && $_POST['login'])
{
$username=$database->clean($_POST['username']);
$password=$database->clean($_POST['password']);
$result = $database->query("SELECT 'id','username','password' FROM 'users' WHERE 'username'='$username' LIMIT 1");
try{
if($database->num_rows($result) == 0){
throw new Exception('User doesnot exist!');
}
$user = $database->fetch($result);
if(md5($password) != $user['password']){
throw new Exception('Invalid username/password!');
}
$_SESSION['user_id'] = $user['id'];
}catch (Exception $e){
echo $e->getMessage();
}
}
/*DISPLAY*/
//echo"<h3 style='text-align:center;'>WAR LEGENDS</h3>";
$output = ob_get_clean();
require('templates/header.php');
echo "<p style='text-align:center;'>". $output ."</p>";
if(!isset($_SESSION['user_id'])){
//require('templates/layout.php');
echo "Welcome to War Legends<br/>";
}
else{
echo"<form action='./' method='POST'>
Username: <input type='text' name='username'/><br/>
password: <input type='password' name='password'/><br/>
<input type='submit' name='login' value='Register'/>
</form>";
}
require('templates/footer.php');
?>
我試圖代碼在線RPG遊戲登陸,並得到索引錯誤,我不能找到一個解決方案請幫助 這是我的代碼,我唐諾如何解決這一問題 通知(!):未定義的索引:登錄在C:\瓦帕\ WWW \ myrpg \的index.php第9行 這是錯誤未定義指數誤差9
檢查「清潔」功能 –
MD5是不夠的密碼哈希。使用['password_hash()'](http://us3.php.net/manual/en/function.password-hash.php)和['password_verify()'](http://us3.php.net/ manual/en/function.password-verify.php)。 –