user6060740
user6060740

Reputation:

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.

Upvotes: 1

Views: 358

Answers (2)

Cathleen Turner
Cathleen Turner

Reputation: 99

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

Upvotes: 2

Mirjalol Bahodirov
Mirjalol Bahodirov

Reputation: 2541

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']);
} 

Upvotes: 2

Related Questions