Reputation: 1310
I'm using jquery mobile 1.4 to create a webapp. I have a form where the user uploads something to the database. After this upload they are redirected to another page where I thought the best thing to do would be to "disable" the back button by checking for a php session variable on the form and if that doesnt exist (they have pressed back after completing their task) the user gets re-directed back to the beginning of the form to prevent them from entering data into the database twice. The code I use for this is
if(!isset($_SESSION['RES_CUSTOMERID'])){
header("Location: my_page_here.php",TRUE,301);
}
However, the my_page_here.php
page uses ajax to load a table that the user can select from. After this redirect the table no longer loads and I have to refresh the page to get any data. I thought that a way round this would be to force a jquery refresh if the customer has come from this page. The way I have done this is:
window.onload = function()
{
if (!window.location.search)
{
setTimeout("window.location+='?fromCustRes';", .10000000);
}
}
Which works however its a bit buggy when using android tab as you can see the flicker. I wanted to "fix" this by making it only refresh if the user has come from this specific page using $_SERVER['HTTP_REFERER'];
and creating a hidden input value to pass this to the jquery and write it into my function but I cant get it to work. This is what I've been trying to do:
<input type='hidden' name='from' id='from' value=<?php echo $from;?> />
window.onload = function()
{
if ((($('#from').val()) === 'my string' )
if (!window.location.search)
{
setTimeout("window.location+='?fromCustRes';", .10000000);
}
}
Ive tried a few variations of this but I cant get anything to work, it just gives me a blank page like I'm breaking the ajax. If anyone has any solutions to this or any better ideas about getting the redirect to load the ajax without a page refresh it would be appreciated!
Upvotes: 0
Views: 344
Reputation:
Try this
echo "<script> window.location.replace(\"index.php\")</script>";
Upvotes: 1