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 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序