| 
 Posted by Flaming Corncob on 06/14/90 11:55 
Below is the code I've come up with. So far it works the way I want it  
to, but I am an amateur at this whole thing and would like to know if  
there's any potential problems with it. It's coded to work in a single  
page, linking to itself instead of linking to other pages. NOTE: It  
doesn't currently check the account ID that is entered against a  
database. That's easy to do. Right now all it does is accept whatever  
the user types in as uses it. 
 
<html> 
 
<? 
if($key!="1701") 
{ 
header("Location:?key=1701&page=page_1"); 
} 
else 
// Start: MAIN BODY 
{ 
session_start(); 
if(!session_is_registered("account_id")) 
{ 
if($page=="post_id") 
{ 
post_id($key); 
} 
} 
else 
{ 
if($page=="member_logout") 
{ 
member_logout($key); 
} 
} 
 
echo "<body>"; 
 
if(!session_is_registered("account_id")) 
{ 
member_login($key); 
} 
else 
{ 
echo "Hello, ".$_SESSION['account_id']."!"; 
if($page!="page_1") 
{ 
echo "<br><a href='?key=$key&page=page_1'>Goto Page 1</a>"; 
} 
else if($page!="page_2") 
{ 
echo "<br><a href='?key=$key&page=page_2'>Goto Page 2</a>"; 
} 
echo "<br><a href='?key=$key&page=member_logout'>Log Out</a>"; 
} 
 
echo "</body>"; 
// End: MAIN BODY 
} 
 
function member_login($key) 
{ 
echo "<form action='?key=$key&page=post_id' method='post'>"; 
echo "Account ID: <input type='text' name='account_id'>"; 
echo "</form>"; 
} 
 
function member_logout($key) 
{ 
session_destroy(); 
header("Location:?key=0"); 
} 
 
function post_id($key) 
{ 
session_register("account_id"); 
$_SESSION['account_id']=$_POST['account_id']; 
header("Location:?key=$key"); 
} 
 
echo "</html>"; 
?>
 
  
Navigation:
[Reply to this message] 
 |