Jump to content

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.
Link to comment
https://forums.phpfreaks.com/topic/13175-redirecting-to-the-previous-page/
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>';
?>
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)
[!--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...............
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
[!--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.
[!--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.
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
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
:)
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.