VBunny Posted June 26, 2009 Share Posted June 26, 2009 I have seen URLs that have a "?subject" added to the "page.php" part, and I was wondering what that did exactly, or what it meant? (Sorry if this seems like a complete newbie question... I can't seem to find the answer just by googling it.) Quote Link to comment https://forums.phpfreaks.com/topic/163753-solved-what-does-pagephpsite-do/ Share on other sites More sharing options...
Adam Posted June 26, 2009 Share Posted June 26, 2009 Take a look here: http://www.php.net/manual/en/language.variables.external.php Quote Link to comment https://forums.phpfreaks.com/topic/163753-solved-what-does-pagephpsite-do/#findComment-864036 Share on other sites More sharing options...
thebadbad Posted June 26, 2009 Share Posted June 26, 2009 The query string component of an URL starts with a question mark, and is normally followed by one or more name=value pairs, separated by ampersands. Those values can then be accessed in e.g. the PHP script, via $_GET['name']. In your example, a single name is only set, without any value. That could be useful if you only need a variable to be set or not set, regardless of any values. E.g.: page.php?login <?php if (isset($_GET['login'])) { //login page will be shown } ?> Quote Link to comment https://forums.phpfreaks.com/topic/163753-solved-what-does-pagephpsite-do/#findComment-864041 Share on other sites More sharing options...
blaatschaap Posted June 26, 2009 Share Posted June 26, 2009 I have seen URLs that have a "?subject" added to the "page.php" part, and I was wondering what that did exactly, or what it meant? (Sorry if this seems like a complete newbie question... I can't seem to find the answer just by googling it.) like thebadbad said the value will be showen like this and you need to check if you "$_GET" anything: <?php if(isset($_GET['login'])){ echo "user login : ".$_GET['login']; } echo "<a href=\"?login=Blaatschaap\">test</a>"; ?> try that script self you also can use multi $_GET like this : <?php if(isset($_GET)){ $login = (isset($_GET['login']) ? $_GET['login'] : 'N/A'); $id = (isset($_GET['id']) ? $_GET['id'] : 'N/A'); $email = (isset($_GET['email']) ? $_GET['email'] : 'N/A'); echo "user login : ".$login."<br/>"; echo "user id : ".$id."<br/>"; echo "user email : ".$email; } echo "<a href=\"?login=Blaatschaap&id=13&email=norply@spam.no\">test</a>"; ?> ~Blaatschaap Quote Link to comment https://forums.phpfreaks.com/topic/163753-solved-what-does-pagephpsite-do/#findComment-864043 Share on other sites More sharing options...
Tonic-_- Posted June 26, 2009 Share Posted June 26, 2009 It can also allow you to partially create multiple webpages in one file.. Basically you can display different content with different requests in the url on one page. Comes in handy if you don't want a lot of files on your hosting to have multiple-web pages. No clutter. Quote Link to comment https://forums.phpfreaks.com/topic/163753-solved-what-does-pagephpsite-do/#findComment-864068 Share on other sites More sharing options...
blaatschaap Posted June 26, 2009 Share Posted June 26, 2009 It can also allow you to partially create multiple webpages in one file.. Basically you can display different content with different requests in the url on one page. Comes in handy if you don't want a lot of files on your hosting to have multiple-web pages. No clutter. yup that's true then its handy to use switch also ~Blaatschaap Quote Link to comment https://forums.phpfreaks.com/topic/163753-solved-what-does-pagephpsite-do/#findComment-864072 Share on other sites More sharing options...
Adam Posted June 26, 2009 Share Posted June 26, 2009 It can also allow you to partially create multiple webpages in one file.. Basically you can display different content with different requests in the url on one page. Comes in handy if you don't want a lot of files on your hosting to have multiple-web pages. No clutter. You'd have a cluttered file? Personally if I were to pass the page name in like that I'd use templates, and a neat file structure. Quote Link to comment https://forums.phpfreaks.com/topic/163753-solved-what-does-pagephpsite-do/#findComment-864081 Share on other sites More sharing options...
Tonic-_- Posted June 26, 2009 Share Posted June 26, 2009 It can also allow you to partially create multiple webpages in one file.. Basically you can display different content with different requests in the url on one page. Comes in handy if you don't want a lot of files on your hosting to have multiple-web pages. No clutter. You'd have a cluttered file? Personally if I were to pass the page name in like that I'd use templates, and a neat file structure. Well it depends how you set it up. To me I know exactly how I setup my pages so I always know what line to goto if need be to add a new entry, but that's just me. Beats editing a crap load of files. Quote Link to comment https://forums.phpfreaks.com/topic/163753-solved-what-does-pagephpsite-do/#findComment-864083 Share on other sites More sharing options...
Adam Posted June 26, 2009 Share Posted June 26, 2009 How many files exactly do you combine into a single file?? Quote Link to comment https://forums.phpfreaks.com/topic/163753-solved-what-does-pagephpsite-do/#findComment-864092 Share on other sites More sharing options...
Tonic-_- Posted June 26, 2009 Share Posted June 26, 2009 Well in my line of work not as many as you would think people would do. Probably 20-30 pages minimal depends on what the file is meant for though. Half of my pages I cut down with mysql queries & run half the page information from just a database which is just depending on the content again. Quote Link to comment https://forums.phpfreaks.com/topic/163753-solved-what-does-pagephpsite-do/#findComment-864099 Share on other sites More sharing options...
VBunny Posted June 26, 2009 Author Share Posted June 26, 2009 Ohh, okay. So how would I write the script to run multiple files in a single file? Quote Link to comment https://forums.phpfreaks.com/topic/163753-solved-what-does-pagephpsite-do/#findComment-864162 Share on other sites More sharing options...
Alex Posted June 26, 2009 Share Posted June 26, 2009 Something like: switch($_GET['page']) { case 1: $content = 'content 1'; break; case 2: $content = 'content 2'; break; default: $content = 'Default content..'; break; } echo $content; Quote Link to comment https://forums.phpfreaks.com/topic/163753-solved-what-does-pagephpsite-do/#findComment-864165 Share on other sites More sharing options...
louis_coetzee Posted June 26, 2009 Share Posted June 26, 2009 Ohh, okay. So how would I write the script to run multiple files in a single file? Create 2 files content1.php and content2.php in same folder as index.php This is index.php below <html> <head> </head> <body> <a href="?page=content1">Content1</a><br> <a href="?page=content2">Content2</a> <?php if (isset($_GET['page']) && FileExists($_GET['page']) .'.php')){ require_once($_GET['page']) .'.php'); }else{ echo 'Page requested not found.'; } ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/163753-solved-what-does-pagephpsite-do/#findComment-864166 Share on other sites More sharing options...
Tonic-_- Posted June 26, 2009 Share Posted June 26, 2009 A common way I know of simply done is something like this <html> <head> <title>My page contents!</title> </head> <body> <? if ($_GET['page'] == "news") { ?> Hello, Lets talk about the news! <? } elseif ($_GET['page'] == "cookies") { ?> Cookies! <? } else { ?> Default homepage text here saying Ello! I am bruno! <? } ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/163753-solved-what-does-pagephpsite-do/#findComment-864169 Share on other sites More sharing options...
blaatschaap Posted June 26, 2009 Share Posted June 26, 2009 i recommend this : <a href="?p=home">Home</a> - <a href="?p=register">Register</a><br/> <?php $p = $_GET['p']; switch($p) { case "home": include "home.php"; break; case "register": include "register.php"; break; default: include "home.php"; break; } ?> case "home" is like it gets ?p=home try the script yourself! Quote Link to comment https://forums.phpfreaks.com/topic/163753-solved-what-does-pagephpsite-do/#findComment-864191 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.