简体   繁体   中英

How to hide get and post parameters from the URL?

I have created a script that posts a value for a certain variable.

HTML:

<form action="post" action="func.php">
       <input name="name"></input>
</form>

func.php:

<?php
  $name = $_GET['name'];
  echo $name;
?>

Output:

Divya Mamgai

But when I check the URL in the address bar I see this:

http://.....func.php?name=Divya%20Mamgai

How can I remove that ?name=Divya%20Mamgai bit from the address bar?

Set your form to method "post". This causes the form to transmit data to the server in the HTTP request body instead of using the URL.

<form action="func.php" method="post">
  <input name="name"></input>
</form>

And then use the $_POST superglobal in PHP:

<?php
  $name = $_POST['name'];
  echo $name;
?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM