SitePoint Sponsor |
|
User Tag List
Results 1 to 6 of 6
-
Mar 7, 2005, 04:00 #1
- Join Date
- Mar 2005
- Location
- Sunderland
- Posts
- 3
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Newbie: probably a daftly simple question about reloading web pages
I am an intermediately-skilled web designer working on a database driven site for my company, and learning php and mysql at the same time. I have what I think is probably a basic question, but I'm stuck with it.
I have created a simple login system that allows users to type in a password (which allows them to see dicounted prices on product pages), and I've put the login form at the top of each page so that viewers can login from anywhere in the site. What I want to do is, after typing in a password, the viewer is taken to a 'login successful/unsuccessful' page and then get taken back to the page they were at. I can take them to the success/fail page but how do I then take them back to the page they logged in on, after a 3-second delay? I need to be able to program this in PHP.
Any help is gratefully appreciated. I'm sure this is just some simple referral code thing, but I'm still learning HTML and CSS as well as PHP and MySQL.
Thanks,
Matt
-
Mar 7, 2005, 04:16 #2
- Join Date
- Nov 2004
- Location
- Ankh-Morpork
- Posts
- 12,158
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
HTML Code:<meta http-equiv="Refresh" content="3;url=/index.php">
Birnam wood is come to Dunsinane
-
Mar 7, 2005, 04:49 #3
- Join Date
- Mar 2005
- Location
- Sunderland
- Posts
- 3
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
This takes me back to the index page, not the previously viewed page. I've been searching through the forums and picked up on code like 'parse_url($HTTP_REFERRER)' - can I use that to somehow replace your reference to index.php? Is there some simple PHP code I can use?
Thanks for your quick response, by the way!
-
Mar 7, 2005, 05:31 #4
- Join Date
- Nov 2004
- Location
- Ankh-Morpork
- Posts
- 12,158
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
If you want it to return to different pages, you'll need to write the URL in your PHP script. The best way would be to supply the URL in a hidden field in the form, and pick it up in the login script.
The next best way might be to use the HTTP 'Referer' (note the spelling error) header, but that's not completely reliable since it can be turned off in some browsers, and also by proxies and firewalls. You could do something like this:
PHP Code:echo '<meta http-equiv="Refresh" content="3;url='
. $_SERVER['HTTP_REFERER']
. '">';
Birnam wood is come to Dunsinane
-
Mar 7, 2005, 05:42 #5
- Join Date
- Mar 2005
- Location
- Sunderland
- Posts
- 3
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
YES!!! Brilliant!
Thanks ever so much!
-
Mar 7, 2005, 18:41 #6
- Join Date
- Dec 2004
- Location
- Sweden
- Posts
- 2,670
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
You could also set a real HTTP header instead of using the META element.
PHP Code:<?php
header("Refresh: 3; $_SERVER['HTTP_REFERER']");
?>Simon Pieters
Bookmarks