donglian6625 2018-04-13 12:27
浏览 35
已采纳

PHP查询不通过表单在db中更新

i'm working on a project that includes a minimail/chat function that has the option to tick off when u have read the message and flag a user.

The flag and tick off options doesnt work anymore after i eddited something but i cannot find the problem anymore.

The game doesnt support newer versions of PHP for now.

  • $m['id']; = 22
  • $m['read'] = 0

Query 1 = array(3) { ["id"]=> string(2) "28" ["mark_read_x"]=> string(2) "10" ["mark_read_y"]=> string(2) "10" }

Query 2 = array(3) { ["id"]=> string(2) "28" ["flag_user_x"]=> string(1) "8" ["flag_user_y"]=> string(1) "4" }

<?php
   $mid = $m['id'];

   if(isset($_POST['mark_read'])){
    $mid2 = $_POST['id'];
    $query2 = "UPDATE `user_messages` SET `read` = '1' WHERE `read` = '0' AND `user_messages`.`id` = '$mid2'";
    mysql_query($query2) or die(mysql_error());
    header("Refresh:0");
    }
?>

<?php if($m['read'] === '0'){ ?>

<form method="post">
   <input type="hidden" name="id" value="<?php echo $mid; ?>">
   <input src="tick.png" title="Mark as read" type="image" alt="submit" name="mark_read">
</form>

<?php } else { echo ''; } ?>

<?php
   if(isset($_POST['flag_user'])){
    $mid2 = $_POST['id'];
    $query3 = "UPDATE `user_messages` SET `flagged` = '1' WHERE `flagged` = '0' AND `user_messages`.`id` = '$mid2'";
    mysql_query($query3) or die(mysql_error());
    header("Refresh:0");
   }
?>

<form method="post">
   <input type="hidden" name="id" value="<?php echo $mid; ?>">
   <input src="exclamation.png" title="Flag message" type="image" alt="submit" name="flag_user">
</form>
  • 写回答

2条回答 默认 最新

  • douqi1931 2018-04-15 14:26
    关注

    Changed

    <input src="tick.png" title="Mark as read" type="image" alt="submit" name="mark_read">
    

    to

    <button type="submit" name="mark_read" style="padding: 0; border: none;"><img title="Mark as read" src="tick.png" /></button>
    

    Input type failed to submit data because of the image type. works fine now.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 有人懂怎么做大模型的客服系统吗?卡住了卡住了
  • ¥20 firefly-rk3399上启动卡住了
  • ¥15 如何删除这个虚拟音频
  • ¥50 hyper默认的default switch
  • ¥15 网站打不开,提示502 Bad Gateway
  • ¥20 基于MATLAB的绝热压缩空气储能系统代码咨询
  • ¥15 R语言建立随机森林模型出现的问题
  • ¥15 关于#wpf#的问题:怎么更改LayoutGroup组件的标签页的字体颜色
  • ¥15 中级微观经济学,生产可能性边界问题
  • ¥15 TCP传输时不同网卡传输用时差异过大