简体   繁体   中英

PHP $_GET hide url

I am writing PHP code for my hosting web page.
I create a search domain filled on page with $_GET to check if domain was available. I need to protect my $GET function in code.

The $GET code to process searching of a domain:

if(isset($_GET['search'])){
$domena = ($_GET['search']);
} 

HTML CODE
I have a submit button with FORM POST ACTION and I get the URL:

www.domain.com/index.php?search=domain.com

I need know if I can hide the URL search=domain.com

Note - I don't want to use AJAX or other language, just PHP.

If you want to hide search parameter, then send it by POST method and accept it by $_POST instead of $_GET.

if(isset($_POST['search'])){
    $domena = ($_POST['search']);
} 

Have you thought about using the $_POST method? The data sent from the user will be in the HTTP request and not in the url. The $_GET method would be posted in the url.

Mozilla does a good job explaining this .

Make sure to specify method $_POST in your form. For example:

<form action="http://foo.com" method="post">
  <input name="say" value="Hi">
  <input name="to" value="Mom">
  <button>Send my greetings</button>
</form>

Then to retrieve your data, use the same code you posted in your question but change $_GET to $_POST

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