0

Currently i'm using a javascript to confirm a form.

echo "<script>
var x = document.URL;
var r = confirm('Are you sure?');
if (r == true) {
window.location.search += '&answer=1'; 
 </script>";

so it add the get param "answer", and in my php file i check the number (if answered "Cancel it returns 0), but i need to delete this param from my url after checking it, but I didn't find anything to do it.

my URL should be like this in the process.

starting url = www.myurl.com

user send the form, and answers "yes" to the question

current url = www.myurl.com?answer=1;

php check the get variable and to things if answered "yes", after finish the function it modified the url

url after php function = www.myurl.com
Devin
  • 7,690
  • 6
  • 39
  • 54
OverHead
  • 13
  • 1
  • possible duplicate of [Request string without GET arguments in PHP](http://stackoverflow.com/questions/9504608/request-string-without-get-arguments-in-php) – George Cummins Sep 11 '14 at 22:50
  • Why not just `redirect` using [PHP header](http://php.net/manual/en/function.header.php), i.e. `header('Location: http://www.myurl.com')` to the `www.myurl.com` after you've done checking in your `PHP` script. – The Alpha Sep 11 '14 at 23:03

2 Answers2

0

You can use this to remove the parameters:

window.location.search = '';
Barmar
  • 741,623
  • 53
  • 500
  • 612
0

To get the current page URL without GET parameters:

console.log(window.location.origin + window.location.pathname);
Niels Keurentjes
  • 41,402
  • 9
  • 98
  • 136