PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 9th, 2000, 01:38 PM
sonya sonya is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2000
Posts: 26 sonya User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > Functions in PHP3

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap