如何在php中銷燬會話?PHP會話銷燬
的事情是當用戶點擊退出按鈕的會議將結束,他將被重定向到的index.php這裏是我的代碼
Customer.php
<?php
session_start();
#include("Connection.php");
if (isset($_POST['submit'])) {
$name = $_POST['customerName'];
$_SESSION['user'] = $name;
}
if (isset($_SESSION['user'])) { echo "Hello {$_SESSION['user']}, welcome back"; }
else{echo "walang tao";}
$sql="INSERT INTO ORDERS(Name) VALUES('$name')";
mysql_query($sql);
session_destroy();
?>
<button><a href="Customer.php"></a></button>
,這是從當用戶想再次登錄
<?PHP
/* this must go before any html */
session_start();
if (isset($_SESSION['user'])) {
header("location: Customer.php");
}
?>
<div class="sign">
<h2>Welcome</h2>
<form action = "Customer.php" method = "POST">
Customer Name:<input type = "text" name="customerName">
<input type = "submit" name = "submit">
</form>
用Customer.php替換index.php –
http://php.net/session_destroy – deceze
當你看到他時,向我問好'Bobby Tables'。 –