I have a button on a file test.php
<?php
$url="http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
?>
<input type="button" name="btn" value="Download" onclick="alert('<?php echo $url; ?>')">
when the file is clicked, it alerts the page’s url.
I have another page, test2.php.
I want the url that is being alerted to be displayed out in test2.php
How can I accomplish this?
Depending on how important it is that it be a button, you could create a form that would send the $url in POST to test2.php. There are many workarounds, but one is the ever-elusive ‘hidden’ input.
The code on test.php would end up looking like:
While the code on test2.php would have to include:
Hope this helps!
Mason
P.S. More information on other ways to do this can be found in this previous question.