Jump to content

Recommended Posts

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!

Link to comment
https://forums.phpfreaks.com/topic/90766-newbie-question-get-through-url/
Share on other sites

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');
}

?>

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

 

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!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.