如何将注释表单添加到使用$ _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

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

You must seperate parameters on a Querystring with &

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

You might need to add some hidden input in your form, so the parameters will be sent to the next page. For example

<input type="hidden" name="user_id" value="'.$_GET['id'].'" >

Also, as mentionned by RiggsFolly answer, you should separate user id and user name, in the href.