mustardman Posted July 10, 2016 Share Posted July 10, 2016 (edited) Typical situation that is called Post/Redirect/Get. I have a custom product details page based on the WHMCS sample provisioning module. https://github.com/WHMCS/sample-provisioning-module I have a form in product details area that posts data into function provisioningmodule_ClientArea($params). The problem is that I cannot clear $_POST information afterwards. So when the browser is refreshed the $_POST data is resent. The typical method to get around this as found on the internet is to use header("Location: " . $_SERVER['REQUEST_URI']);exit(); That should reload the browser, clear $_POST, and return me to /clientarea.php?action=productdetails&id=xxxx. However it takes me back to clientarea.php?action=services. Can't figure out why. The 'REQUEST_URL is correct but WHMCS doesn't like it for some reason and goes back to clientarea.php?action=services unset($_POST) and $_POST = array(); doesn't clear it because it needs to be cleared from the browser not in PHP. Edited July 10, 2016 by mustardman 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted July 11, 2016 Share Posted July 11, 2016 share this code used to clear and redirect please? 0 Quote Link to comment Share on other sites More sharing options...
mustardman Posted July 11, 2016 Author Share Posted July 11, 2016 (edited) I figured out how to get around it. I think WHMCS needs $_POST if you are staying on the same page because it includes the service/product ID. I ended up creating a variable in $_SESSION to track when a form has been posted once so it's not posted a second time on browser refresh. if ($_SESSION['submitted'] == 1 && !isset($_POST['customformdata'])) { unset($_SESSION['submitted']); } .. .. if ($_SESSION['submitted' != 1]) { //Do some stuff with $_POST custom form data $_SESSION['submitted'] = 1; } Edited July 11, 2016 by mustardman 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.