後,我要讓我的更改默認菜單登錄通過後 和 我有一些代碼對我的應用程序是這樣PHP製作隱藏和顯示菜單登錄
的index.php
<?php session_start(); ?>
<html>
<head></head>
<body>
<ul>
<?php if($_SESSION['loggedIn'] == '1'): ?>
<li><a href="../templates/" title="Home" id="activated">Home</a></li>
<li><a href="catalog.html" title="Catalog" >Catalog</a></li>
<li><a href="signup-for-partners.html" title="Partners">Become Our Partner</a></li>
<li><a href="About-us.html" title="About Us">About Us</a></li>
<?php else: ?>
<li><a href="../templates/" title="" >Home</a></li>
<li><a href="account.html" title="" >My Account</a></li>
<li><a href="catalog.html" title="" >Catalog</a></li>
<li><a href="logout.php" title="" >logout</a></li>
<?php endif; ?>
</ul>
</body> </html>
這是我與驗證碼
<?php
session_start();
include 'conection.php';
if($_POST['captcha'] == $_SESSION['captcha']){
$username = $_POST['UserID'];
$password =$_POST['Password'];
$sql = "select * from login where username='".$username."' and password='".$password."'";
#echo $sql."<br />";
$query = mysql_query($sql) or die (mysql_error());
if($query){
$row = mysql_num_rows($query);
if($row > 0){
$_SESSION['loggedIn']='1';
$_SESSION['UserID']=$username;
header('Location: ../templates/');
}
else {
header('Location: error.php');
}
}
}
else{
header('Location: ../templates/');
}
?>
過程及其可能出現的錯誤這樣
公告:未定義的索引:在的loggedIn C:\ XAMPP \ htdocs中\模板\的index.php上線78
只是process.php
定義爲什麼它不工作的loggedIn?
哪裏的html表單爲此? –
'$ _SESSION ['loggedIn'] ='0';'如果。 'mysql_'函數已被棄用。你必須照顧SQL注入..等..等 –
當然希望你打算採取這種生活。你現在擁有的是完全不安全的。 –