开发者

How to hide get and post parameters from the URL?

开发者 https://www.devze.com 2023-02-12 17:55 出处:网络
I have created a script that posts a value for a certain variable. HTML: <form action=\"post\" action=\"func.php\">

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%2开发者_StackOverflow0Mamgai 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;
?>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号