dougongyou7364 2018-04-26 08: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 09: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条)
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部