beachboy4231 Posted February 12, 2008 Share Posted February 12, 2008 I am a total newbie to PHP. I am trying to teach myself the software just because it's so awesome. I've been going through the pages at W3 and creating my own "database application" on my server that really has no point except to be a training aid. Here is what I want to do. I have my index.php file and a userlogin.php file. I want to be able to have a link to the userlogin.php file in the index.php file and when that link is clicked go to the url "mysite.com/index.php?page=login". That page would have all the normal content of my "index.php" with the login page included I know I'm going to have to somehow use the GET variables, but how? An example of what I'm talking about is here on Wikipedia: http://en.wikipedia.org/w/index.php?title=Special:Userlogin Does anyone even know what I'm talking about? Thanks a lot! Quote Link to comment https://forums.phpfreaks.com/topic/90766-newbie-question-get-through-url/ Share on other sites More sharing options...
elpaisa Posted February 12, 2008 Share Posted February 12, 2008 Hi, One advice, if you want to improve your knowledge quickly, you should start using some existent script, firstly study it and afther modify it, that's better. If you insist doing it that way here is something that should help first <?php if(isset($_GET['page']) == 'login') { include('loginpage.php'); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/90766-newbie-question-get-through-url/#findComment-465268 Share on other sites More sharing options...
toplay Posted February 12, 2008 Share Posted February 12, 2008 To access the value of "login" from this: mysite.com/index.php?page=login you would use $_GET['page'] For forms, it's best to use $_POST instead. Look in our tutorial section and below is a link to the PHP manual that will help: http://us.php.net/manual/en/reserved.variables.php#reserved.variables.get Quote Link to comment https://forums.phpfreaks.com/topic/90766-newbie-question-get-through-url/#findComment-465270 Share on other sites More sharing options...
beachboy4231 Posted February 12, 2008 Author Share Posted February 12, 2008 Elpaisa, I will definitely try looking at some already written code. In the mean time, here is what I tried: <body> <a href="/index.php?page=login">User Login</a> <?php if(isset($_GET['page']) == 'login') { include('userlogin.php'); } ?> </body> Unfortunately, when I tried clicking the link, my browser gave me a 404 error. "The requested URL /index.php was not found on this server." Any advice? Thanks again! Quote Link to comment https://forums.phpfreaks.com/topic/90766-newbie-question-get-through-url/#findComment-465275 Share on other sites More sharing options...
elpaisa Posted February 12, 2008 Share Posted February 12, 2008 Try this: <a href="index.php?page=login">User Login</a> Or this <?php echo '<a href="'. RewriteLink('index.php?page=login') .'">User Login</a>'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/90766-newbie-question-get-through-url/#findComment-465285 Share on other sites More sharing options...
beachboy4231 Posted February 12, 2008 Author Share Posted February 12, 2008 Try this: <a href="index.php?page=login">User Login</a> That did it! I guess it was that extra forward slash I had in there, how embarrassing. haha Thanks a lot! Quote Link to comment https://forums.phpfreaks.com/topic/90766-newbie-question-get-through-url/#findComment-465289 Share on other sites More sharing options...
elpaisa Posted February 12, 2008 Share Posted February 12, 2008 Ok, please mark it as solved Quote Link to comment https://forums.phpfreaks.com/topic/90766-newbie-question-get-through-url/#findComment-465300 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.