PDA

View Full Version : php login using session not working.


spider
08-16-2002, 06:13 AM
im trying to develope a program, and the login wont log me in. the script generates a .dat file, when user registers. no problem there, everything in the .dat file... username and password, but when i go an log in under that username and password, it gives me the message that, that username or password isnt correct.

here the code for the login form:

<table><tr>
<form method='post' name='login' action='loginin.php'>
<td>User ID:</td>
</tr>
<td><input name='id' type='text'></td>
</tr>
<td>Password:</td>
</tr>
<td><input name='pass' type='password'></td>
</tr>
<td><input type='submit' name='submit' value='Login'></form></td>
</tr></table>

here the code for the loginin.php

<?
session_start();
session_register("user");
$user = "$id";
include("config.php");
$file = "/member/$user.pass.dat";
if (file_exists($file))
{

include("/member/$user.pass.dat");

if (($id == $user) and ($pass == $password))
{
header("SET-COOKIE: logedin=$id; expires=Monday, 07-Jan-2005 00:00:00 GMT;");

echo "<meta http-equiv='Refresh' content='2; URL=$site_url/stats.php'>";

}
else
{
echo "<center>You Entered the wrong username or password</center>";
echo "<center><PRE>
<form method='post' name='login' action='loginin.php'>
Login
User ID: <input name='id' type='text'>
Password: <input name='pass' type='password'></td></tr>
<input type='submit' name='submit'><input type='Reset'></form>";
}

}
else
{
echo "<center>You Entered the wrong username or password</center>";
echo "<center><PRE>
<form method='post' name='login' action='loginin.php'>
Login
User ID: <input name='id' type='text'>
Password: <input name='pass' type='password'></td></tr>
<input type='submit' name='submit'><input type='Reset'></form>";
}

?>

If i take out one else statment, i get this error:

Parse error: parse error in loginin.php on line 30

thats why i leave it in...

the $user.pass.dat file has this in it:

<? $user='admin'; $password='k4tm4nn'; ?>

and in the members folder, the $user is same as admin

like this:

admin.pass.dat

any suggestions?

stuntboy
08-16-2002, 06:40 PM
Is register_globals turned on or off? As I dont see anything jumping out at me as wrong. Also since you are using php 4.2.2 I would switch to the new way of dealing with sessions (which fits in with the register_globals on or off thing)

So you would refer to all your vairables posted from a form with:
$_POST['variableName']

The Get Variables with:
$_GET['variableName']

Server variables
$_SERVER['variableName']

Cookies:
$_COOKIE['cookieName']

and of course session variables :)
$_SESSION['sessionVariable']


and for sessions with the new $_SESSION variables there is no need to register them anymore, you only need to set them, this makes sessions easier

<?
session_start();
$_SESSION['user'] = $_POST['id'];
include("config.php");
$file = "/member/$user.pass.dat";
if (file_exists($file))

you would reffer to the variable pass with $_POST['pass']

BTW HI all :)

spider
08-18-2002, 01:46 PM
register_globals = On

yep. on, and i tried your code, but it did the exact same thing...

ill tell you what im trying to work on... a paid email script... for people to sign up, get paid, what the company wants to pay per each email,,, and letting other companies sign up with the program,,, through paypal, and paying people who sign up to read emails, with paypal... id like to use mysql, which all that hasnt been a problem...

my only problem so far has been a system to signup, login, and track users, ive tried mysql logins, and others,,, but for some reason, dont want to work,,,,,

this is my php.ini

http://www.spidermonster.com/php.ini.txt

which i dont know what to use for what anyhow...

i dont know if i would need any certain dll's loaded or not...

but, says register_globals are on,,,

i really cant understand why i cant get session's to work.. and i thank you for taking the time to look..

spider
08-18-2002, 09:02 PM
sorry, my phpinfo.php is here,,,dont know what all i need for this all to work...

http://www.spidermonster.com/phpinfo.php