Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 05-28-2005, 07:37 AM small help plz
feraira's Avatar
BeTheBand!

Posts: 350
Trades: 0
heres the scenario... you view a news story on a website so you want 2 post something back, so u log in, u get redirected to the main page again, which is quite annoying as you will have to go through all the links and pages again to get to where you were... how can i solve this by making the redirect go back?

this is what i have atm
Code:
$back = "<javascript:history.back(-1)>";

?>

<html>
<META HTTP-EQUIV="Refresh" CONTENT="1;URL=<? echo "$back"; ?>">
</html>
feraira is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-28-2005, 07:46 AM
Unknown.

Posts: 1,693
Trades: 0
You could just make the login script to take you to the correct page instead of the mainpage.. include a hidden field in the form named redirect..

<input type="hidden" name="redirect" value="postcomment.php" />

then when you process the form with php check whether there is a value for the redirect box and if there is take them to that page specified otherwise just go to the main page..

PHP Code:
$redirect $_POST['redirect'];
if(
$redirect) {
header('location: $redirect');
exit;
} else {
header('location: mainpage.php');
exit;

more reliable than using javascript.. saves the time to..
Dark-Skys99 is offline
Reply With Quote
View Public Profile
 
Old 05-28-2005, 01:00 PM
leavethisplace's Avatar
Ultra Talker

Posts: 297
Trades: 0
Nah, when you go to login, get the login PHP script to simply look up where the user just came from by using the pretty cool $_SERVER predifined.

Quote:
'HTTP_REFERER'
The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted.
to use this, use $_SERVER['HTTP_REFERER'];

You will have to get the login script to check that a) there is a refering page, if not what do you do!? b) check the refering page is actually your website
__________________
A lie gets halfway around the world before the truth has a chance to get its pants on. - Sir Winston Churchill

Please visit my sites:
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
leavethisplace is offline
Reply With Quote
View Public Profile
 
Old 05-28-2005, 06:18 PM
feraira's Avatar
BeTheBand!

Posts: 350
Trades: 0
lol, ok then.. that doesnt really help .. it does, but not the kinda answer im looking for... how can i make the javascript code into a variable to use? cos when it redirects it uses that in the browser? which is annoying
feraira is offline
Reply With Quote
View Public Profile
 
Old 05-28-2005, 07:38 PM
the12thplaya's Avatar
Experienced Talker

Posts: 38
Trades: 0
Not using java script as I don't know enough of it, but this is how I got around a similar problem using PHP, perhaps you can use it with your javascript somehow?

At the top of each page, except the login page use:

$_SESSION[currentPage] = $PHP_SELF;

Which will store the current page url you're looking at in a global session variable

When referring back to that page, ie. redirecting put this code at the top of the page maybe your login page or, the page that checks login details:

$currentPage = $_SESSION[currentPage];

And then after login is approved you can direct them to the page stored in the $currentPage variable
the12thplaya is offline
Reply With Quote
View Public Profile Visit the12thplaya's homepage!
 
Reply     « Reply to small help plz
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.15246 seconds with 12 queries