dougongyou7364 2018-04-26 16:44
浏览 28
已采纳

如何将注释表单添加到使用$ _GET生成的页面

I'm making a website and basically, I made one page called "user.php" and I'm using $_GET to make it so it shows different profiles depending on what the URL is. Now I want to make a comment form so that anyone can post a comment on a specific user's profile. I've tried making the form but when I submit it, it reloads the page and I lose the data in the URL that allowed me to access someone's profile. So I was wondering is it possible to do what I want to do or do I have to use $_POST and make it create one different page for every single user?

To illustrate it here's an example of what I'm asking:

Index.php

<?php echo '<a href="user.php?id='.$row['user_id'].'_user='.$row['username'].'">'; ?>

User.php(?id=1_user=poop)

<form action="" method="POST" id="comment_form">
<textarea></textarea>
<input type="submit" value="Submit" />
</form>

If I click on the submit input, I get back to the URL User.php without any data sent to the server

  • 写回答

3条回答 默认 最新

  • dongmuyan5638 2018-04-26 17:24
    关注

    You forgot to add a &.

    Try Using:

    echo '<a href="user.php?id=' . $row['user_id'] . '&' . '_user=' .$row['username']. '">';
    

    Also remember:

    • GET requests can be cached
    • GET requests remain in the browser history
    • GET requests can be bookmarked
    • GET requests should never be used when dealing with sensitive data
    • GET requests have length restrictions
    • GET requests is only used to request data (not modify)

    — from w3schools.com

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

报告相同问题?

悬赏问题

  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥20 测距传感器数据手册i2c