Terabyte
Terabyte

Reputation: 455

Set new values on the url

I have a url which is showing two values posted using a GET method in php. I can get the values from the url using this example -

suppose the url is http://example.com/?name=Hannes

My code

 <?php
    echo 'Hello ' . htmlspecialchars($_GET["name"]) . '!';
    ?>

And the output Hello Hannes!

My question is- how can I set the values to the url on button click method post eg.

<form method="POST">
if(isset($_POST['$btn'){

 htmlspecialchars($_GET["name"])="Lucky";   /*If there is something like this*/

}
</form>

Thank you.

Upvotes: 0

Views: 26

Answers (1)

Sougata Bose
Sougata Bose

Reputation: 31749

Try with -

if(isset($_POST['$btn'){

    header('location:yourpage.php?name='.$yourValue);
    exit;   

}

Upvotes: 1

Related Questions