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 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵