index.php contains only php and basically just queries a database and then loads the information into the current page with the links in it.
This page with all the links in it, also contains a form which when submitted, inserts the information into a database table and is then redirected to the current page:
$WA_redirectURL = “?sent=true”;
On this current page, the first ‘confirm’ paragraph below is supposed to be shown:
<?php if(isset($_GET[‘sent’]) && $_GET[‘sent’] == “true”) { ?> <p id=“confirm” style=“background-color: #ded5b3; color: #00274c; padding: 5px; margin-bottom: 8px;”> <strong>Thank you – your details have been processed. </strong></p><?php } else { ?>
<p>Subscribe to our newsletter.</p>
<?php } ?>
It doesn’t seem to work though because even though it’s submitting to itself, it’s not loading the current page because it needs certain information in the url string to do this (see the abovementioned link). When the submit button is pressed the following is at the end of the url:
index.php?sent=true
Since index.php is the php page that only queries the database the page shown is blank and not the page that was previously seen, before submitting the form.
I just wondered if anyone knows of a workaround for this problem?
The problem is that the query string parameters will be different for each link on the page so how would I account for that? I just need it to redirect to the exact same page as it was before submitting the form, ie. the user would be looking at the same information from the database.
As was said before, adjust the form action to include those querystring parameters.
The form action determines where the form is submitted. When the form action includes querystring parameters, any other form values are added on to that query string.
You can use $_SERVER[‘REQUEST_URI’] to retrieve the URI that was used to access the page, including querystrings.
There is a work-around, where you also use the hidden form value that mrwooster mentioned, and check for that using $_POST[‘sent’]
Although, normally a more accepted solution is to check for the name of the submit button instead.