Reply to Re: login php sessions

Your name:

Reply:


Posted by Chris White on 04/30/05 10:31

Quinonez wrote:
> Im having a problem, which in my head seems to be simple but i cannot
> figure it out.
>
> there are 3 pages.
>
> Page 1 (login form)
>
> page 2 (verifies login/pass and begins session. has link to page 3)
>
> Page 3 (displays some info has a link back to page 2)
>
> obviously i only want pages 2 and 3 to be able to be accessed through
> the login.
>
> i can get to page 2 and page 3 after login no problem but IF i press
> the link on page 3 to page 2 it takes me back to page 1 and i have to
> login again.
>
> here is the code
>
> Page 1 (admin.php)
> .....
>
> <form method="post" action="edit_site.php">
> Name: <input type="text" name="username">
> Password: <input type="text" name="password">
> <input type="submit" value="ENTER">
> </form>
> .....
>
> Page 2 (edit_site.php)
>
> <?php
> session_start();

ok, looks reasonable to me.


>
> if($affected_rows == 1) {
> $_SESSION['username'] = $username;

using $_SESSION, ok..

> }
> else {
> header( "Location: admin.php" );
> }
>
> ?>
>
> Page 3 (edit_news.php)
>
> <?php
> session_start();
> if(session_is_registered('user name')){

Er.. session_is_registered+$_SESSION = bad. I think
IsSet($_SESSION['username']); is what you're looking for. Also, I think
you need to re-intialize your session variable when going back to page 2:

$_SESSION['username'] = $username; as you did in the previous page.


Hope this helps.

Chris White

[Back to original 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

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