You are here: Re: Session Log In « All PHP « IT news, forums, messages
Re: Session Log In

Posted by Flaming Corncob on 08/18/06 02:08

In article <d3506$44e41fe5$c2ab6db8$3585@news1.tudelft.nl>,
"Frits van Leeuwen" <Frits.vanLeeuwen@nospam.nl> wrote:

> "Flaming Corncob" <you@wish.com> schreef in bericht
> news:you-B7CD21.23094913082006@news.west.earthlink.net...
> > 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:&nbsp;<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>";
> > ?>
>
> What does this do?
>
> if($key!="1701")
> {
> header("Location:?key=1701&page=page_1");
> }
> else
> ...

It checks to see it you've visited the site already. If you did, key
should be set to 1701. If not, it sets the key and page and reloads.
Dunno any other way of doing it.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация