SomeoneSpecial99 Posted September 8, 2013 Share Posted September 8, 2013 Im trying to create a index file for my site that receives arguments like this: "someonespecial99.com/?p=pagenamehere" The thing i need help with is getting the ?p= function, Can anyone help me with this please? thx Link to comment Share on other sites More sharing options...
SomeoneSpecial99 Posted September 8, 2013 Author Share Posted September 8, 2013 an example i found is "http://ac3-servers.eu", When you click a button in left sidebar then it will use ?p=whateva.php to retrieve the page Link to comment Share on other sites More sharing options...
Labtec Posted September 8, 2013 Share Posted September 8, 2013 Good evening, So you want to be able to display certain pages depending on $_GET variables passed via URL? Kind regards, Lab. Link to comment Share on other sites More sharing options...
SomeoneSpecial99 Posted September 8, 2013 Author Share Posted September 8, 2013 Good evening, So you want to be able to display certain pages depending on $_GET variables passed via URL? Kind regards, Lab. Yes Link to comment Share on other sites More sharing options...
Ingolme Posted September 8, 2013 Share Posted September 8, 2013 A simple example is to include a file: simply: include $_GET['p'] . '.php'; For security, there are restrictions, a simple way to restrict is to only allow a few names: if(!isset($_GET['p']) { $_GET['p'] = '';}switch($_GET['p']) { case ''; case 'home': include 'home.php'; break; case 'about': include 'about.php'; break; case 'contact': include 'contact.php'; break; default: // Send a 404 Not Found header header('HTTP/1.0 404 Not Found'); include '404.php';} Link to comment Share on other sites More sharing options...
SomeoneSpecial99 Posted September 9, 2013 Author Share Posted September 9, 2013 (edited) A simple example is to include a file: simply: include $_GET['p'] . '.php'; For security, there are restrictions, a simple way to restrict is to only allow a few names:if(!isset($_GET['p']) { $_GET['p'] = '';}switch($_GET['p']) { case ''; case 'home': include 'home.php'; break; case 'about': include 'about.php'; break; case 'contact': include 'contact.php'; break; default: // Send a 404 Not Found header header('HTTP/1.0 404 Not Found'); include '404.php';} Sorry, Im still kinda new at php so I have 1 problem that has arose This is the code i used: <?phpinclude $_GET['q'] . '.php';if(!isset($_GET['q']) { // $q=$_GET["q"]; $_GET['q'] = '';}switch($_GET['q']) { case ''; case 'home': include 'home.html'; break; case 'about': include 'about.php'; break; case 'contact': include 'contact.php'; break; default: // Send a 404 Not Found header header('HTTP/1.0 404 Not Found'); include '404.php';}?> And this is the error (DreamWeaver said syntax error aswell) Parse error: syntax error, unexpected '{' in /home/someone1/public_html/index.php on line 3 Any help please? btw: this file is currently hosted at http://www.someonespecial99.com/index.php Edited September 9, 2013 by SomeoneSpecial99 Link to comment Share on other sites More sharing options...
astralaaron Posted September 9, 2013 Share Posted September 9, 2013 (edited) if(!isset($_GET['q']) { in this line of the code there is a missing ")" : it should be: if(!isset($_GET['q'])) { Edited September 9, 2013 by astralaaron Link to comment Share on other sites More sharing options...
Ingolme Posted September 9, 2013 Share Posted September 9, 2013 I forgot a closing parenthesis, as astralaaron pointed out. It was an easy mistake to find, given the error messages. Learning to debug error messages on your own is an important skill. It tells you exactly where the error is occurring so you can look there and see what's wrong. Link to comment Share on other sites More sharing options...
SomeoneSpecial99 Posted September 9, 2013 Author Share Posted September 9, 2013 if(!isset($_GET['q']) {in this line of the code there is a missing ")" : it should be: if(!isset($_GET['q'])) { I forgot a closing parenthesis, as astralaaron pointed out. It was an easy mistake to find, given the error messages. Learning to debug error messages on your own is an important skill. It tells you exactly where the error is occurring so you can look there and see what's wrong. Ok, now that I have raged at my debugging failure (I could see that problem but not see it ~_~) I had a bug where the import occurred twice, But out of self debugging fixed it, Thanks for all the help Link to comment Share on other sites More sharing options...
Labtec Posted September 9, 2013 Share Posted September 9, 2013 Good evening, Have you got it working? Kind regards, Lab. Link to comment Share on other sites More sharing options...
SomeoneSpecial99 Posted September 9, 2013 Author Share Posted September 9, 2013 Good evening, Have you got it working? Kind regards, Lab.Hi Lab,Yes, I have managed to get it fully working as expected,Thanks for the help everyone ;P Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now