Jump to content


Photo

Redirecting To The Previous Page


  • Please log in to reply
9 replies to this topic

#1 Dville

Dville
  • Members
  • PipPipPip
  • Advanced Member
  • 88 posts

Posted 29 June 2006 - 04:28 AM

I have a link on one page. . .to a page containing this is the 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");

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.

#2 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 29 June 2006 - 04:31 AM

<?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>';
?>
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#3 Dville

Dville
  • Members
  • PipPipPip
  • Advanced Member
  • 88 posts

Posted 29 June 2006 - 04:37 AM

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)

#4 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 29 June 2006 - 05:00 AM

[!--quoteo(post=389102:date=Jun 29 2006, 04:37 AM:name=Dville)--][div class=\'quotetop\']QUOTE(Dville @ Jun 29 2006, 04:37 AM) View Post[/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...............
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#5 Dville

Dville
  • Members
  • PipPipPip
  • Advanced Member
  • 88 posts

Posted 29 June 2006 - 05:05 AM

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

#6 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 29 June 2006 - 05:21 AM

[!--quoteo(post=389113:date=Jun 29 2006, 05:05 AM:name=Dville)--][div class=\'quotetop\']QUOTE(Dville @ Jun 29 2006, 05:05 AM) View Post[/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.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#7 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 29 June 2006 - 05:28 AM

header('Location: ' . $_SERVER['HTTP_REFERER']);
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#8 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 29 June 2006 - 05:30 AM

[!--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) View Post[/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.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#9 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 29 June 2006 - 05:33 AM

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
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#10 Dville

Dville
  • Members
  • PipPipPip
  • Advanced Member
  • 88 posts

Posted 29 June 2006 - 05:33 AM

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
:)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users