Ask a Question related to PHP Development, Design and Development.
-
Chip #1
session problem - login screen continually reloads after pressing the login button
I am trying to get sessions to work on a log in screen to give certain
users access to certain pages/directories. The problem is that when
the login button is pushed (or the enter key pressed) the login screen
redraws, never loading the next page. I don't get any error messages.
I am using FreeBSD-5.1/Apache-2.0.46/MySQL-4.1.0.1/PHP-4.4.3.4
Thanks,
Chip
I have pasted the code below -
This is at the top of the page login.php -
-------------
<?
session_start();
session_register("userid","password");
if ($submit)
{
$db=mysql_connect("localhost","user","") or die ("Error in this querymysql_select_db("simradusa",$db) or die ("Error in this query >>$sql<<>>$sql<< : " .mysql_error());
: " .mysql_error());
$result=mysql_query("select * from user where userid = '$userid'",$db)
or die ("Error in this query >>$sql<< : " .mysql_error());
while ($row=mysql_fetch_array($result))
{
if ($row["userpassword"]==$password)
{
header('Location:
[url]http://xxx.xxx.xxx.xx/auth_dealers/dealers_page.php');[/url]
}
}
}
?>
------------
This is at the top of all pages, before any html tags -
-------------
<?
session_start();
if(!isset($userid)) {
header('Location: [url]http://xxx.xxx.xxx.xx/auth_dealers/login2.php');[/url]
exit;
}
?>
Chip Guest
-
Strange problem with Forms authentication: After successfull login, login page is still displayed
Hi there I have a quite strange problem with my ASP.NET-Application. The application has being deployed one year ago and worked fine till last... -
Login/Applicationtoken/Session Variable Problem
I am having a problem with Logging in and Session variables. I am new to ColdFusion, but program in other languages including PHP and Java. Recently... -
Problem with Login Feature By Login Wizard...Please Help
Hello everyone. I am a beginner and am currently learning Coldfusion MX 7. I ran the login wizard with simple authentication on a folder I want to... -
Login to admin system through login screen only
Hi there, I have an issue relating to login to my asp.net application. Basically i have built the standard login page which compares against the... -
The login Screen
Press CTRL -> ALT -> DEL at the welcome screen -- good luck! Please Send Reply only in newsgroup Tim -
Matthias Esken #2
Re: session problem - login screen continually reloads after pressing the login button
Chip <carvin5string@yahoo.com> schrieb:
And you're using code from the times of PHP 4.0.x.> I am trying to get sessions to work on a log in screen to give certain
> users access to certain pages/directories. The problem is that when
> the login button is pushed (or the enter key pressed) the login screen
> redraws, never loading the next page. I don't get any error messages.
> I am using FreeBSD-5.1/Apache-2.0.46/MySQL-4.1.0.1/PHP-4.4.3.4
Don't use short tags. The are not portable. Use <?php.> <?
Seems OK. :-)> session_start();
That's not good. In fact it is bad style. Read the documentation at> session_register("userid","password");
[url]http://www.php.net/manual/en/function.session-register.php[/url].
You rely on register_globals=on. Since PHP 4.2.0, the default value for> if ($submit)
register_globals is off.
Ouch. What is $userid? You might believe that it contains a variable> This is at the top of all pages, before any html tags -
> -------------
> <?
> session_start();
> if(!isset($userid)) {
> header('Location: [url]http://xxx.xxx.xxx.xx/auth_dealers/login2.php');[/url]
> exit;
> }
> ?>
from your session. If register_globals is off, then it doesn't and PHP
will always send you back to login2.php. You'll find the value in
$_SESSION['userid'] instead. If register_globals is on, then it _might_
contain the id from the session. On the other hand it could be a clever
intruder who just calls your page with page.php?userid=42. So, don't
work with activated register_globals.
This leaves you with some work to do. Check the setting of
register_globals in the php.ini. If it's on, then switch it off. With
activated register_globals you have to work hard to make your code
secure. With deactivated register_globals you have to work to make it
insecure.
To find errors from uninitialized variables set the error_reporting to
E_ALL, so that you get all notices and warnings during the development
of your code.
Write data to a session with:
$_SESSION['example'] = $value;
Access data in a session with:
echo ($_SESSION['example']);
Access data from a form with:
$_POST['username']
or
$_GET['username']
according to your posting method.
Check [url]http://www.php.net/manual/en/language.variables.predefined.php[/url] for
details about these "superglobals".
Regards,
Matthias
Matthias Esken Guest



Reply With Quote

