How to remove $_GET parameters from URL after one time use

Ishaq asked
get
via

Could you please help me? After clinking the button when i reload the page, i need to remove the GET parameter and not to show the thanks massage again.

<?php 
if(isset($_GET['status'])){
$thanks="Hi, Thank you for this single click!";
}
?>

<html>
<a href="?status=data" ><button>Giving Thanks</button></a>
<h4><?php echo $thanks;?></h4>
</html>


Answer
via

You can change your code to the following.

<?php 
if(isset($_POST['status'])) {
    $thanks = 'Hi, Thank you for this single click!';
}
?>

<html>
<form method="post" action="">
    <input type="hidden" name="status" value="data" />
    <button type="submit">Giving Thanks</button>
</form>
<?php if(!empty($thanks)) : ?>
    <h4><?php echo $thanks;?></h4>
<?php endif; ?>
</html>
Share This
Posted in: