Dville Posted June 29, 2006 Share Posted June 29, 2006 I have a link on one page. . .to a page containing this is the code[code]// Make a MySQL and database connectionmysql_connect("localhost","user","pass") or die(mysql_error());mysql_select_db("database") or die(mysql_error());$aprid = $_GET['appid'];mysql_query("UPDATE articles SET hits = hits + 1 WHERE id='$aprid'");header("Location: http://localhost/digg/index.php");[/code]Now, that I have multiple pages, that go to this blah.php page. . .i would like it to redirect them to the page they came from(with a refresh to show the changes).I tried doing with this java. . .and using a 'history.back' type command. . .but when just going 'back', it doesnt refresh the page to show the changes. And I don't want to add a java to the current page, to make it refresh every time.Thanks in advanced. Quote Link to comment https://forums.phpfreaks.com/topic/13175-redirecting-to-the-previous-page/ Share on other sites More sharing options...
redarrow Posted June 29, 2006 Share Posted June 29, 2006 <?php// refresh / redirect to an internal web page// ------------------------------------------header( 'refresh: 5; url=/webdsn/' );echo '<h1>You will be re-directed in 5 seconds...</h1>';// refresh / redirect to an internal web page// ------------------------------------------header( 'refresh: 3; url=/' ); # redirects to our homepageecho '<h1>You will be re-directed in 3 seconds...</h1>';// refresh / redirect to an external web page// ------------------------------------------header( 'refresh: 0; url=http://www.example.net' );echo '<h1>You won\'t know what hit you!</h1>';?> Quote Link to comment https://forums.phpfreaks.com/topic/13175-redirecting-to-the-previous-page/#findComment-50670 Share on other sites More sharing options...
Dville Posted June 29, 2006 Author Share Posted June 29, 2006 Sorry, I know how to do this. . .but since I will have this specific code in Many pages, the hit.php page(code shown above) will have requests coming from multiple files. . .so using a specific url doesn't help me at this moment. . .as you see above, that's what it does(and automaticly refreshes, since it's not java) Quote Link to comment https://forums.phpfreaks.com/topic/13175-redirecting-to-the-previous-page/#findComment-50672 Share on other sites More sharing options...
redarrow Posted June 29, 2006 Share Posted June 29, 2006 [!--quoteo(post=389102:date=Jun 29 2006, 04:37 AM:name=Dville)--][div class=\'quotetop\']QUOTE(Dville @ Jun 29 2006, 04:37 AM) [snapback]389102[/snapback][/div][div class=\'quotemain\'][!--quotec--]Sorry, I know how to do this. . .but since I will have this specific code in Many pages, the hit.php page(code shown above) will have requests coming from multiple files. . .so using a specific url doesn't help me at this moment. . .as you see above, that's what it does(and automaticly refreshes, since it's not java)[/quote]you point the redirect to a page with only another redirectin sending them back to the oreginal page thats updated............... Quote Link to comment https://forums.phpfreaks.com/topic/13175-redirecting-to-the-previous-page/#findComment-50682 Share on other sites More sharing options...
Dville Posted June 29, 2006 Author Share Posted June 29, 2006 maybe i'm missing something.let me try to explain this some morepage1.php, page2.php, and page3.php have code that sends a request to hit.php(the code shown in my first post). This contains a certain table id field number so that it knows what specific field to update.But since i have about 30 of the 'page#.php' pages, hit.php will get requests from many many different pages, and there will be know way of knowing exactly which one to redirect back to.I hope this helps Quote Link to comment https://forums.phpfreaks.com/topic/13175-redirecting-to-the-previous-page/#findComment-50683 Share on other sites More sharing options...
redarrow Posted June 29, 2006 Share Posted June 29, 2006 [!--quoteo(post=389113:date=Jun 29 2006, 05:05 AM:name=Dville)--][div class=\'quotetop\']QUOTE(Dville @ Jun 29 2006, 05:05 AM) [snapback]389113[/snapback][/div][div class=\'quotemain\'][!--quotec--]maybe i'm missing something.let me try to explain this some morepage1.php, page2.php, and page3.php have code that sends a request to hit.php(the code shown in my first post). This contains a certain table id field number so that it knows what specific field to update.But since i have about 30 of the 'page#.php' pages, hit.php will get requests from many many different pages, and there will be know way of knowing exactly which one to redirect back to.I hope this helps[/quote]The resulting page should be a members profile page do add the ?&id=$id to the redirect link to profiles. Quote Link to comment https://forums.phpfreaks.com/topic/13175-redirecting-to-the-previous-page/#findComment-50689 Share on other sites More sharing options...
.josh Posted June 29, 2006 Share Posted June 29, 2006 header('Location: ' . $_SERVER['HTTP_REFERER']); Quote Link to comment https://forums.phpfreaks.com/topic/13175-redirecting-to-the-previous-page/#findComment-50691 Share on other sites More sharing options...
redarrow Posted June 29, 2006 Share Posted June 29, 2006 [!--quoteo(post=389121:date=Jun 29 2006, 05:28 AM:name=Crayon Violent)--][div class=\'quotetop\']QUOTE(Crayon Violent @ Jun 29 2006, 05:28 AM) [snapback]389121[/snapback][/div][div class=\'quotemain\'][!--quotec--]header('Location: ' . $_SERVER['HTTP_REFERER']);[/quote]know that looks good what that do please exsplain cheers....will the command carry the users session information back from the page they have been cheers. Quote Link to comment https://forums.phpfreaks.com/topic/13175-redirecting-to-the-previous-page/#findComment-50692 Share on other sites More sharing options...
.josh Posted June 29, 2006 Share Posted June 29, 2006 it redirects you to the page that called the script. for example, if you have page1.php and you call (as in, click a link from, or click a submit button and post vars to, etc..) page2.php, and in page2.php you do that command up there, it redirects you back to page1.php Quote Link to comment https://forums.phpfreaks.com/topic/13175-redirecting-to-the-previous-page/#findComment-50693 Share on other sites More sharing options...
Dville Posted June 29, 2006 Author Share Posted June 29, 2006 I don't see where you're getting confused. I can do everything. . .BUT, I want to change the header line in the hit.php(code shown in the first post). . .to something that will redirect to whatever page the request came from.so if a change was made from page2.php, after doing the change, i want it to redirect back to page2.php. but remember i have about 30 pageX.php pages.So since the redirect is happening on hit.php, and not pageX.php. I can't just put one static URL, which is how i have it now, just so it works, and doesn't dead end. The redirect will be a wildcard/variable basicly. . .but i get lost there.EDIT - lol, sweet. . .lemme try thatEDIT. . .part 2 - thanks crayon that works perfectly:) Quote Link to comment https://forums.phpfreaks.com/topic/13175-redirecting-to-the-previous-page/#findComment-50694 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.