0
我試圖保留每個會話的數據。當你看到代碼和屏幕截圖時,你會明白。如何使頁面中的不同會話的數據保持不變php
<?php
require('connect.php');
session_start();
if(isset($_SESSION['email'])) {
echo "Your session is running " . $_SESSION['email'];
echo "</br></br>";
}
$a=$_SESSION['email'];
$sql = "SELECT title, content FROM post";
$result = mysqli_query($connection, $sql);
if (mysqli_num_rows($result) > 0) {
// output data of each row
while($row = mysqli_fetch_assoc($result)) {
echo "Posted by: $a </br> Title: " . $row["title"]. " </br> Content: " . $row["content"]. "</br></br>";
}
} else {
echo "0 results";
}
?>
<html>
<head></head>
<body>
<form action="post.php" method="post">
You can add new content or <a href='logout.php'>Logout</a></br></br>
Your Email:</br>
<input type="text" required autocomplete="off" name="email"/></br></br>
Title:</br>
<input type="text" required autocomplete="off" name="title"/></br></br>
Content:</br>
<textarea rows="4" cols="50" required autocomplete="off" name="content">
</textarea></br></br>
<input type="submit" value="Send">
</form>
</body></html>
當我與[email protected]登錄。它看起來像那樣; First
但是當我用@ a登錄時。它看起來像那樣; Second
我想保留每個會話的每個內容。當我用[email protected]輸入某些內容並從此會話中註銷後。我想看到「發佈者:[email protected]」(我的意思是,寫有該內容的電子郵件) 也與其他會話。我沒有看到我當前的會話郵件每次。我怎樣才能做到這一點 ?
Omg,我問完全錯誤的東西..對不起。我的意思是我如何將會話電子郵件添加到數據庫?不介意在屏幕截圖中發送電子郵件表單,那麼我怎樣才能看到電子郵件? – Unicepter