Reputation: 455
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
Reputation: 31749
Try with -
if(isset($_POST['$btn'){
header('location:yourpage.php?name='.$yourValue);
exit;
}
Upvotes: 1