Lessur Posted July 28, 2006 Share Posted July 28, 2006 I have seen many sites with somethig like:www.domainhere.com/?page=newsAnd then another page like www.domainhere.com/?page=otherHow can I do that? ??? Quote Link to comment Share on other sites More sharing options...
Ninjakreborn Posted July 28, 2006 Share Posted July 28, 2006 They are get queriesused in universal pages or the likeAll it means ishttp://www.whatever.comthat is the domain namehttp://www.whatever.com/index.phpthat is the filename that you are on, the homepage in this casehttp://www.whatever.com/index.php?name=west&born=1983That is the domain name, followed by the page they are onthe question mark ends hte actual url information and starts variable informationthere just php variables, this becomes$name = "west";$born = 1983;what would be that those values are assigned to those variables on the next page USING the get command$_GET['name']$_GET['born']the first variable contains "west" the second containes 1983Then you have other symbols for other things, if the variables values contain spaces, you see + for every space, if there are other special characters they automatically get url encoded. Quote Link to comment Share on other sites More sharing options...
Ninjakreborn Posted July 28, 2006 Share Posted July 28, 2006 Like you can take and do this with like 20 url'sand have 1 page handle all of those url's based on the contents of the get variables, and have it use the location header to redirect them to the appropriate pages, it can severely cut down on the number of pages on your server. Quote Link to comment Share on other sites More sharing options...
Lessur Posted July 28, 2006 Author Share Posted July 28, 2006 I dont really understand. I am talking about for example a site like http://thesmurk.net/. When you click on "Flash" for example the new address is http://thesmurk.net/?page=flash Quote Link to comment Share on other sites More sharing options...
Ninjakreborn Posted July 28, 2006 Share Posted July 28, 2006 [code]?page=flash[/code]That simply means as I statesthe ? ends the actual url information and starts the variablesthe variable page is set to teh word flash$page = flash;is how you would do it, or how it would look in php.this probably tells a redirecting page to send it to the flash version of the site, or could be for something else, or something used in the script to decide whether to activate flash or not. Could be many reasons. Quote Link to comment Share on other sites More sharing options...
Ninjakreborn Posted July 28, 2006 Share Posted July 28, 2006 Oh I just checked it,if it's set to flash it displays the flash elements, if you take it off, the flash elements are x-ed out. Quote Link to comment Share on other sites More sharing options...
Ninjakreborn Posted July 28, 2006 Share Posted July 28, 2006 or they could be testing the browser for flash, and if it exists it shows that, if not it doesn't, it could be anythign. Quote Link to comment Share on other sites More sharing options...
Lessur Posted July 28, 2006 Author Share Posted July 28, 2006 [quote author=businessman332211 link=topic=102191.msg405273#msg405273 date=1154109356][code]?page=flash[/code]That simply means as I statesthe ? ends the actual url information and starts the variablesthe variable page is set to teh word flash$page = flash;is how you would do it, or how it would look in php.this probably tells a redirecting page to send it to the flash version of the site, or could be for something else, or something used in the script to decide whether to activate flash or not. Could be many reasons.[/quote]So basically, in another page there is $page = flash; ? And when you say www.blah.com/?page=flash it goes to the page that has $page = flash; in it? Quote Link to comment Share on other sites More sharing options...
king arthur Posted July 28, 2006 Share Posted July 28, 2006 [quote author=Lessur link=topic=102191.msg405270#msg405270 date=1154109183]I dont really understand. I am talking about for example a site like http://thesmurk.net/. When you click on "Flash" for example the new address is http://thesmurk.net/?page=flash[/quote]In your example:What will happen is that the same page (the one at http://thesmurk.net/) will be loaded. But this time around, a variable will be set in the superglobal array $_GET, with the value "flash". The script would access this variable by looking at $_GET["page"].It might use this in a switch statement, e.g.if(isset($_GET["page"])){switch($_GET["page"]){ case "flash": .....do some flash stuff..... break; default: .....do something else...... break;}} Quote Link to comment Share on other sites More sharing options...
Ninjakreborn Posted July 28, 2006 Share Posted July 28, 2006 No that sets the variable.It means that if you set that,http://www.domain.com/index.php?page=flashlike if you have in a linkindex.php?page=flashthey click on that, on the index.php page if you type outecho $page;it's going to sayflashit just registers the variable with the value for use on the next page.Even if it's a quick script to see which one was set for redirection. Quote Link to comment Share on other sites More sharing options...
Ninjakreborn Posted July 28, 2006 Share Posted July 28, 2006 exacly like he states above. With that example, that is exactly how I was meaning for redirect. Quote Link to comment Share on other sites More sharing options...
unkownname Posted July 28, 2006 Share Posted July 28, 2006 quick and simple code for you.EX URL: http://example.com/index.php?id=1if(isset($_GET['id'])){$id=$_GET['id'];}else{$id=0; //this is not very necessary//}switch($id){case 1://EX: This is were the url goes to.//include("news.php");break;case 2://EX: Include about//include("about.php");break;default;//EX : Include home page//include("home.php");}FOR Words just put case 'word': //Make sure it has " ' " because it prob will screw up with " not sure its been a while Quote Link to comment Share on other sites More sharing options...
Lessur Posted July 28, 2006 Author Share Posted July 28, 2006 Would that code code into my index.php (My home page.) or Shoudl I make that code index.php and the old index.php index2.php? Hehe, sorry but Im a newb when it comes to php :'( Quote Link to comment Share on other sites More sharing options...
Ninjakreborn Posted July 28, 2006 Share Posted July 28, 2006 It has to be applied in the form of a link, there has to be some point when someone clicks on a link to have hte query string there.You could have a front page, that says click here for flash version, or here for non flash versionnon flash version has no code the other is like<a href="index.php?page=flash">Flash Version</a>That sends hte variable $page = flashacross to the other page, so you can activate the flash or whateveror you can send to another redirect pageand haveif ($_GET['page'] == "flash") {$page = "indexwithflash.php";header('Location: ' . $page);}else {$page = "index.php"; // regular index page with no flashheader('Location: ' . $page);}Even still you can do something like have the variable disable and enable flash as necessary, Quote Link to comment Share on other sites More sharing options...
king arthur Posted July 28, 2006 Share Posted July 28, 2006 [quote author=Lessur link=topic=102191.msg405287#msg405287 date=1154110700]Would that code code into my index.php (My home page.) or Shoudl I make that code index.php and the old index.php index2.php? Hehe, sorry but Im a newb when it comes to php :'([/quote]What is it that you're actually trying to do? Quote Link to comment Share on other sites More sharing options...
Lessur Posted July 28, 2006 Author Share Posted July 28, 2006 I want to have something like www.domain.com/?page=pagehere.For example, if I went to my domain. It would come up on index.php. And say I have a link to info. I want to be able to make that link www.domain.com/?page=info. I also have a link to flash, with, there a link to each persons flash. I wnat to be able to say www.domain.com/?page=flash&user=usernameofuser . How can I do such a thing? I already have all the pages. Quote Link to comment Share on other sites More sharing options...
Ninjakreborn Posted July 28, 2006 Share Posted July 28, 2006 That's not going to happen, being limited to just passing get variables. You need some kind of login if you don't already have one, plus either sessions or cookies. On top of that you need to pass the variables necessary, and even in this particular situation passing get variables between urls for this, would be pointless, you should automatically generate the url's via db interacting into the session variables, when they first login, and pass that information from page to page, this will save you a lot of time, and a lot of headaches, and be a little more secure. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.