...Noobie $PHP_SELF question
Moderator: General Moderators
...Noobie $PHP_SELF question
I've been fiddling around and came up with the idea: "Hmm... when I switch skins, why don't I just stay on the page I originally was on, instead of being redirected to the index.php page"
But I've been fiddling around *of course* and haven't seemed to have found the answer. I'm sure it's something simple, and I'm sure you're all getting annoyed with having to deal with the same person every day ^_^, with the same code (plus the changes of a previous question).
Right now, as it is, if I am on "gallery.php" and decide to switch "skins" by clicking ?index.php?ver=blah... it then redirects to index.php... My question, as I kind of stated above, is that I want to be able to view index.php?id=gallery while at the same time changint the skin. I've noticed that doing index.php?id=gallery&ver=blah changes it and all, but I need a way to input a variable instead of gallery, so that I can click a link from any page and click index.php?id=anypage&ver=blah so that I switch versions, but not pages...
As I said earlier, I'm sure it's something really obvious, but it escapes me... But you'll be happy to know that I did something on my own in php, and didn't have to rely on someone else for help! For once, heh. This is not one of those situations, however! All help is appreciated. And feyd... You still rock for your rescripting of my original code ^_^... Edit: Well actually, not all of my original code, just the "page identification" part ^_^;
But I've been fiddling around *of course* and haven't seemed to have found the answer. I'm sure it's something simple, and I'm sure you're all getting annoyed with having to deal with the same person every day ^_^, with the same code (plus the changes of a previous question).
Right now, as it is, if I am on "gallery.php" and decide to switch "skins" by clicking ?index.php?ver=blah... it then redirects to index.php... My question, as I kind of stated above, is that I want to be able to view index.php?id=gallery while at the same time changint the skin. I've noticed that doing index.php?id=gallery&ver=blah changes it and all, but I need a way to input a variable instead of gallery, so that I can click a link from any page and click index.php?id=anypage&ver=blah so that I switch versions, but not pages...
As I said earlier, I'm sure it's something really obvious, but it escapes me... But you'll be happy to know that I did something on my own in php, and didn't have to rely on someone else for help! For once, heh. This is not one of those situations, however! All help is appreciated. And feyd... You still rock for your rescripting of my original code ^_^... Edit: Well actually, not all of my original code, just the "page identification" part ^_^;
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
This thread is all but too general.
In your index.php, before you have your function to include the requested page, or any page for that matter, have a function something along these lines..
For each different style you want, have a different style sheet.
edit| forgot to mention you'll need to set the session for it to remember to use your "remembered" style.. beat me too it though feyd
In your index.php, before you have your function to include the requested page, or any page for that matter, have a function something along these lines..
Code: Select all
if (!empty($_GET['vers']))
{
echo '<link href="'.$_GET['vers'].'.css" rel="stylesheet" type="text/css">';
}
else
{
echo '<link href="default.css" rel="stylesheet" type="text/css">';
}edit| forgot to mention you'll need to set the session for it to remember to use your "remembered" style.. beat me too it though feyd
Last edited by John Cartwright on Mon Mar 21, 2005 9:32 pm, edited 1 time in total.
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
you can use a session variable to record the current/last page a person was on. Then redirect back to it when processing an event which would need a redirection... Or, you can link to the current URL with added variables to make the switch transparently (sorta)
viewtopic.php?t=30090
viewtopic.php?t=30090
Well, my original question (although it probably wasn't worded right..) was how to get a current url (like http://www.blah.com/index.php?id=blah) and make a variable equal that, so that the code
Edit: And I tried to fiddle with that session thing... It doesn't work on my server (something about globals being off and such...)
Code: Select all
<a href="e;$variable&ver=blah"e;></a>
Last edited by theda on Tue Mar 22, 2005 6:57 am, edited 1 time in total.
If you did it this way:theda wrote:Edit: And I tried to fiddle with that session thing... It doesn't work on my server (something about globals being off and such...)
Code: Select all
<?php
session_start();
session_register("variable name");
?>Try doing it the "new" way:
Code: Select all
<?php
session_start();
$_SESSION['variable name'] = 123123123;
?>So, for your style sheet thing:
Code: Select all
<?php
session_start();
if(isset($_GET['skin']))
{
$_SESSION['skin'] = $_GET['skin'];
}
if(!isset($_SESSION['skin']))
{
$_SESSION['skin'] = 'default';
}
// Then you'd use $_SESSION['skin'] as the name of your style sheet in the link tag. Sorry, got to go...
?>Pyrite, that's kind already what my script does (with the skins)... The only difference now is that I want to change a skin on page (blah.com/?id=BLAH) and still remain on that page after I change the skin. Currently, How it is coded, it redirects back to the blah.com page.
Edit: Traherom, I don't want to use Sessions. I am using cookies and only cookies. Thanks for the help though.
And excuse the late response, I was in Seattle and had limited access to computers (argh! vacations!...)
Edit: Traherom, I don't want to use Sessions. I am using cookies and only cookies. Thanks for the help though.
And excuse the late response, I was in Seattle and had limited access to computers (argh! vacations!...)
I found another website that does exactly what I want my script to do:
http://www.spoono.com <-- Awesome site indeed! Well, on their website, you'll notice "Flavors" at the top right. If you click one of them, it changes colors... But if you go to one of their tutorials, and then click a "Flavor", it'll stay on the page that you were viewing (the tutorial). That is what I want it to do...
http://www.spoono.com <-- Awesome site indeed! Well, on their website, you'll notice "Flavors" at the top right. If you click one of them, it changes colors... But if you go to one of their tutorials, and then click a "Flavor", it'll stay on the page that you were viewing (the tutorial). That is what I want it to do...