|
|
Posted by Flaming Corncob on 08/18/06 02:07
In article <f38c4$44e42495$c2ab6db8$4709@news1.tudelft.nl>,
"Frits van Leeuwen" <Frits.vanLeeuwen@nospam.nl> wrote:
> > > Is it posible to do this all in 1 file?
> > > I Like to start with INDEX.PHP
> > > There I like to login or choose a language.
> > > After a bad login, I like to say it's wrong.
> > > After a good login, I like to say hello+username.
> > > Bad or good, you can choose always a language.
> >
> > I just posted my own code... using a 1-page format. It works.
>
> Thanks for your reaction.
> I tried you code, but it does not work.So I take a look and try to
> understand why it's not working. I make some changes, but it still does not
> work.
> Can you take a look why it's not working?
>
> <html>
>
> <?php
> $base_link="http://www.Leeuwendeel.info".$_SERVER['PHP_SELF'];
> ?>
>
> <?php
> // what happen here?
> if($key!="1701")
> {
> header("Location:$base_link?key=1701&page=page_1");
> }
> else
> // Start: MAIN BODY
> {
> session_start();
> if(!session_is_registered("account_id"))
> {
> if($page=="post_id")
> {
> post_id($key, $base_link);
> }
> }
> else
> {
> if($page=="member_logout")
> {
> member_logout($key, $base_link);
> }
> }
>
> echo "<body>";
>
> if(!session_is_registered("account_id"))
> {
> member_login($key, $base_link);
> }
> else
> {
> echo "Hello, ".$_SESSION['account_id']."!";
> if($page!="page_1")
> {
> echo "<br><a href='$base_link?key=$key&page=page_1'>Goto Page 1</a>";
> }
> else
> {
> if($page!="page_2")
> {
> echo "<br><a href='$base_link?key=$key&page=page_2'>Goto Page 2</a>";
> }
> echo "<br><a href='$base_link?key=$key&page=member_logout'>Log Out</a>";
> }
> }
> echo "</body>";
> // End: MAIN BODY
> }
>
> function member_login($key, $base_link)
> {
> echo "<form action='$base_link?key=1701&page=post_id' method='post'>";
> echo "Account ID: <input type='text' name='account_id'>";
> echo "</form>";
> }
>
> function member_logout($key, $base_link)
> {
> @session_destroy();
> header("Location:$base_link?key=0");
> }
>
> function post_id($key, $base_link)
> {
> session_register("account_id");
> $_SESSION['account_id']=$_POST['account_id'];
> header("Location:$base_link?key=0");
> }
>
> echo "</html>";
> ?>
// what happen here?
> if($key!="1701")
> {
> header("Location:$base_link?key=1701&page=page_1");
> }
> else
I have it set up so whenever anyone visits the site it checks "key" to
see if my page set it. If it's not set to 1701 it is assumed you're
visiting the site for the first time, sets the key to 1701 and the page
to the start up. Dunno any other way to do it, so I did it this way.
As far as it not working, off hand I don't see anything wrong.. could be
you're using an older version of PHP? I'll keep looking at it closer.
[Back to original message]
|