1

Is there a way to submit an input field value without getting its name in the URL?

I use a form with method GET for search, when I submit the form, I get something like this:

/file/?inputname=value

I want to get it this way:

/file/value

Otherwise: if the first solution is not possible, how can I modify the .htaccess to rewrite the URL in the above way(I mean: /file/?inputname=value), but please take in mind I use 2 parameters in the URL dir1/file/?inputname=value .

Thanks in advance

DevManX
  • 476
  • 3
  • 14

4 Answers4

2

Try this: Solution Here

Use .htaccess like below

RewriteEngine On
RewriteRule ^(.*)$ /index.php?url=$1 [L]

To a user on your site, they will see and navigate to this:

http://example.com/value

But the real page would be something like this:

http://example.com/index.php?inputname=value

This bit, [L], tells the server that this is the last line of the rewrite rule and to stop.

Community
  • 1
  • 1
I'm Geeker
  • 4,601
  • 5
  • 22
  • 41
0

set your form method to post

<form method="post" ...

and in your PHP file receive data like this

$inputValue = $_POST['inputname'];
Kuldeep Dangi
  • 4,126
  • 5
  • 33
  • 56
0

First is not possible.

.htaccess:

Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l

RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]

PHP

    $url = rtrim($_GET['url'], '/');
    $url = filter_var($url, FILTER_SANITIZE_URL);
    $url = explode('/', $url);

    $part1 = (isset($url[0]) ? $url[0] : null);
    $part2 = (isset($url[1]) ? $url[1] : null);
    $part3 = (isset($url[2]) ? $url[2] : null);
    $part4 = (isset($url[3]) ? $url[3] : null);
    $part5 = (isset($url[4]) ? $url[4] : null);

/*
$partN will contain the input after the URL. 
If URL was http://foo.com/this/is/fun
$part1 = this
$part2 = is
$paer3 = fun
*/
0

You have to use post method.

NOTE:The data sent by POST method goes through HTTP header so security depends on HTTP protocol. By using Secure HTTP you can make sure that your information is secure.

REFERENCE

ALSO for rewrite rules,try this

RewriteEngine on
RewriteRule ^dir1/file/$ http://www.my.domain.com/dir1/file [QSA,L]
Priyank
  • 3,778
  • 3
  • 29
  • 48