Ok what I want to do is allow someone to enter their memberID and be able to access a lot of information. The "lot of information" should be dynamic so that the user can click on a link and be taken to a section of that chunk of information.

For example, here I am creating a "switch" with 2 functions. When someone enters their memberID (from another page) they are taken to the initial_page function. That works fine. But when they click on "View Contact Info", the page just refreshes itself to the initial page.

The memberID is stored in a cookie is being accessed from each function.

The cookie is set as:

<?php
if ($memberID != '') //if there is a cookie stored
{
SetCookie("memberID",$memberID, time()+3600000); //Set the cookie with the name
}
else //else if the cookie does not exist
{
Header("Location: index.php3");
}
?>


I can't figure out why -- here's my code, if anyoneee can help ASAP plzzz...

<?
mysql_connect("site", "uname", "password");

#define action constants
define (initial_page, 0);
define (view_contact, 1);
/*define (edit_contact, 2);
define (view_billing, 3);
define (edit_billing, 4);
define (edit_password, 5);
define (email_us, 6);*/

/*functions go here*/

function display_initial ($memberID)
{
global $PHP_SELF;

$query = "SELECT memberID, password, First_Name, date_updated, status
FROM Applicants
WHERE memberID = '$memberID'";

$result = mysql_db_query("db", $query);

if ($result) {
while ($r = mysql_fetch_array($result)) {
$memberID = $r["memberID"];
$password = $r["password"];
$First_Name = $r["First_Name"];
$date_updated = $r["date_updated"];
$status = $r["status"];

echo "<h1>&nbsp;<a href=$PHP_SELF?action=initial_page>Home</a><br>&nbsp;<a href=$PHP_SELF?action=view_contact>View Contact Info</a><br>
&nbsp;<a href=$PHP_SELF?action=edit_contact>Edit Contact Info</a></h1>";

echo "<p>Welcome, $First_Name!";
echo "<p>Your last update was made on $date_updated";
echo "<p><strong>Your current status:</strong> $status";
}
}

else {
echo "No member ID exists";
}
mysql_free_result($result);
}

function display_contact ($memberID)
{
global $PHP_SELF;

$query = "SELECT memberID, password, First_Name, Last_Name, Address1, Address2, City, Province, Country, Postal_Code, Email, Fax
FROM Applicants
WHERE memberID = '$memberID'";

$result = mysql_db_query("db", $query);

if ($result) {
while ($r = mysql_fetch_array($result)) {
$memberID = $r["memberID"];
$password = $r["password"];
$First_Name = $r["First_Name"];
$Last_Name = $r["Last_Name"];
$Email = $r["Email"];
$Address1 = $r["Address1"];
$Address2 = $r["Address2"];
$City = $r["City"];
$Province = $r["Province"];
$Country = $r["Country"];
$Postal_Code = $r["Postal_Code"];
$Fax = $r["Fax"];

echo "<p><strong>First Name:</strong> $First_Name";
echo "<p><strong>Last Name:</strong> $Last_Name";
echo "<p><strong>Email:</strong> $Email";
echo "<p><strong>Address:</strong> $Address1 $Address2";
echo "<p><strong>City:</strong> $City";
echo "<p><strong>Province/State:</strong> $Province";
echo "<p><strong>Country:</strong> $Country";
echo "<p><strong>Postal Code:</strong> $Postal_Code";
echo "<p><strong>Fax:</strong> $Fax";
}
}

else {
echo "No member ID exists";
}
mysql_free_result($result);
}

if (empty ($action))
{
$action = initial_page;
}

switch ($action)
{
case initial_page:
display_initial ($memberID);
break;
case view_contact:
display_contact ($memberID);
break;
/*case edit_contact:
modify_contact ();
break;
case view_billing:
display_billing ();
break;
case edit_billing:
modify_billing ();
break;
case edit_password:
modify_password ();
break;
case email_us:
send_email ();
break;*/
default:
die("Unknown action code ($action)");
}
?>

Please help!!

Thanks,
Sana