Jump to content
Updating IPB tonight Read more... ×

Archived

This topic is now archived and is closed to further replies.

Dville

Redirecting To The Previous Page

Recommended Posts

I have a link on one page. . .to a page containing this is the code

[code]// Make a MySQL and database connection
mysql_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.

Share this post


Link to post
Share on other sites
<?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 homepage
echo '<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>';
?>

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites
[!--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...............

Share this post


Link to post
Share on other sites
maybe i'm missing something.

let me try to explain this some more

page1.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

Share this post


Link to post
Share on other sites
[!--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 more

page1.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.

Share this post


Link to post
Share on other sites
[!--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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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 that

EDIT. . .part 2 - thanks crayon that works perfectly
:)

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.