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 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 R语言卸载之后无法重装,显示电脑存在下载某些较大二进制文件行为,怎么办
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?
  • ¥15 关于#vue.js#的问题:修改用户信息功能图片无法回显,数据库中只存了一张图片(相关搜索:字符串)
  • ¥15 texstudio的问题,