HTML Form Method = HASH?

If I set the Form method to GET, it will send an action page something like this:

action_page.php?key=value&foo=bar

      

But is there a way to do it like this:

action_page.php#key=value&foo=bar

      

Because the page getting the values ​​depends on hash variables.

Thanks!

+1


a source to share


4 answers


you can set up a "middle man" page that redirects data like this:

middleman.php:

<?php

$string = 'realpage.php#' . $_SERVER['QUERY_STRING'];

header('location: ' . $string);

?>

      



so in your form, you would do:

<form action="middleman.php" method="get">

      

and this will send to middleman.php which inturn will redirect to realpage.php with hash.

+3


a source


You can do this using javascript by adding:



window.location.hash

      

+2


a source


You can use javascript to dynamically generate such URL parameters from form values.

0


a source


Are you sure the page depends on "hash variables"? This would be a very strange way to design a system. In particular, the items after the hash are not guaranteed to be sent by the browser to the server, and in fact, in most cases, they are not. This means that your PHP script will never get variables.

-1


a source







All Articles