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

Posted by Flaming Corncob on 10/11/80 11:55

In article <1155530116.976117.42690@74g2000cwt.googlegroups.com>,
"Flamer" <die.spam@hotmail.com> wrote:

> Flaming Corncob wrote:
>
> > 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>";
> > ?>
>
> header("location: needs to be a full url starting with http://, also
> you probably want to put an @ at the start of the @session_destroy
> command, not needed, however if a cookie isnt set on their pc (ie they
> refreshed the logout page) they will get an ugly error.
>
> Flamer.

Ok, than is there a way to have it default to a specific page.. for
example if I were to use BASE to have links default to one page? I tried
using BASE in this situation but as it's used in the "head" tag it scews
up a session.

 

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

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