gpt4 book ai didi

PHP 删除收件箱无法正常工作

转载 作者:可可西里 更新时间:2023-11-01 07:08:58 24 4
gpt4 key购买 nike

我有一个用于删除消息的收件箱代码。

如果我选择一条消息,它会删除所有消息。

我该如何解决这个问题?

这是我的 delete_message.php 代码:

$inboxbtn = $_POST['deleteinbox'];
$outboxbtn = $_POST['deleteoutbox'];

if($inboxbtn){
$selectall = $_POST['selectall'];
if($selectall){
$query = mysql_query("SELECT * FROM messages WHERE to_user='$user'");
while ($row = mysql_fetch_assoc($query)){
mysql_query("UPDATE messages SET to_delete='1' WHERE to_user='$user'");
}
echo "All messages have been deleted.";
}
else{
$query = mysql_query("SELECT * FROM messages WHERE to_user='$user'");
while ($row = mysql_fetch_assoc($query)){
$msg_id = $row['id'];
$value = "cb"."$msg_id";
$checkbox = $_POST[$value];
if ($value){
mysql_query("UPDATE `messages` SET `to_delete`='1' WHERE `to_user`='$user' AND `id`='$msg_id'");
}
}
echo "The selected messages have been deleted.";
}

}elseif ($outboxbtn){
$selectall = $_POST['selectall'];
if($selectall){
$query = mysql_query("SELECT * FROM messages WHERE from_user='$user'");
while ($row = mysql_fetch_assoc($query)){
mysql_query("UPDATE messages SET from_delete='1' WHERE from_user='$user'");
}
echo "All messages have been deleted.";
}
else{
$query = mysql_query("SELECT * FROM messages WHERE from_user='$user'");
while ($row = mysql_fetch_assoc($query)){
$msg_id = $row['id'];
$value = "cb"."$msg_id";
$checkbox = $_POST[$value];
if ($value){
mysql_query("UPDATE messages SET from_delete='1' WHERE to_user='$user' AND id='$msg_id'");
}
}
echo "The selected messages have been deleted.";
}
}
else
echo "Choose a message to delete.";

这是 inbox.php 中带有复选框的代码

$query = mysql_query("SELECT * FROM messages WHERE from_user='$user' AND from_delete='0' ORDER BY id DESC");
$numrows = mysql_num_rows($query);
if ($numrows != 0){
echo "<form action='delete_message.php' method='POST'>";
echo "<div class='messages'>
<div class='leftside'><input type='checkbox' name='selectall'><input type='submit' name='deleteoutbox' value='Delete' class'button'></div>
<div class='rightside'>Date</div>
Subject And Message
<div class='clear'></div>
<hr>
</div>";
while ($row = mysql_fetch_assoc($query)){
$msg_id = $row['id'];
$msg_to_user = $row['to_user'];
$msg_to_id = $row['to_id'];
$msg_from_user = $row['from_user'];
$msg_from_id = $row['from_id'];
$msg_subject = $row['subject'];
$content = nl2br($row['content']);
$msg_date = $row['date'];
$msg_from_delete = $row['from_delete'];
$msg_to_delete = $row['to_delete'];

if(!$msg_from_delete){
echo "<div class='messages'>";
echo "<div class='leftside'>
<input type='checkbox' name='cb$msg_id' value='$msg_id'>
<a href='profile.php?id=$msg_to_id' target='_blank'>$msg_to_user</a>
</div>";

echo "<div class='rightside'>$msg_date</div>";

echo "<div id='center' style='margin-left:150px; margin-right:150px;'>

<span class='toggle'><a href='#' onClick='return false'>$msg_subject</a></span>
<div class='hiddenDiv'>
<br /><hr>
<b>$smiles </b>
<br><br>


</div>
</div>";

echo "<div class='clear'>";
echo "<br /><br /><hr>";
echo "</div></div>";
}
}
echo "</form>";
}
else
echo "You Have No Messages In Your Outbox"

然后对于收件箱消息,它与发件箱相同,但采用收件箱形式。

我该如何解决这个问题?

最佳答案

与其直接评估一个被来自 POST、GET 全局变量的数据填充的变量,不如先使用 isset() 函数来检查他们是否得到了任何值,然后可以将此 isset 函数的返回值提供给如果用于评估。

eg : $inboxbtn = $_POST['deleteinbox'];
$outboxbtn = $_POST['deleteoutbox'];
if(isset($inboxbtn)){
$selectall = $_POST['selectall'];
if(isset($selectall)){

}
}

我觉得你在这方面有问题,检查一下.... http://in2.php.net/isset https://www.virendrachandak.com/techtalk/php-isset-vs-empty-vs-is_null/

关于PHP 删除收件箱无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22728280/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com