Jump to content

Help with PHP navigation and passing variables.


barefootsanders

Recommended Posts

Hey everyone.  I've been stuck on this problem for some time now.  I have a web server that I run on my computer and I have been developing my own user login database.  The problem that I am having is viewing the user info page.  Each user has their own unique user ID and I would like to have that ID used in the link for their userinfo page.  Here is the format of my page.  I have a main index.php. On each click the page is reloaded and in the center I have the following switch statement.

 

<?php

$page = $_GET['page'];

switch ($page)
{
	case register: //Register was clicked
		include("register.php");
		break;
	case welcome: //The main home page
		include("welcome.php");
		break;
	case forgotpass: //Forgot password was clicked
		include("forgotpass.php");
		break;
	case userinfo: //User info page
		include("userinfo.php?id");
		break;
	case useredit: //User edit page
		include("useredit.php");
		break;
	case admincenter: //Admin center - FOR ADMINS ONLY!
		include("admin/admin.php");
		break;
	default:
		include("welcome.php");
}
?>

Links are set up like this:

echo "<a href=\"index.php?page=userinfo\">My Account</a>";

 

Now I have been trying for about a week or so to incorporate the ID's into the link but to no avail.  I have tried to include things like:

echo "<a href=\"index.php?page=userinfo?id=$_SESSION['userid']\">My Account</a>";

 

But it does not work.  At the top of my userinfo page I would like to take the id passed through the link clicked and use that to search the database and retrieve the array with the userinfo.  Using this array I would print to the screen the information stored in that array.

 

Has anyone else seen this type of navigation before and if so could you show me how to get through this?? Thanks a lot in advance.

Link to comment
Share on other sites

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.