Forum Moderators: coopster

Message Too Old, No Replies

problem in login panel

piece of code working fine at a site and showing errors on the other site

         

xs2Manish

11:43 am on Nov 14, 2005 (gmt 0)

10+ Year Member



i have piece of code for admmin login panel. It is working perfectly fine on my local machine. but it is not working on the clients server. but the same coding was working on another application. i used it and just changed the db name. erro msg displayed is "could not log you in"
this is displyed if as the session variable i not being initialised . but i could not figure out the reason for this
<?php
session_start();

if(isset($user) && isset($pass))
{
$db=mysql_connect('localhost','root','');
if(!$db)
{
echo "Cannot connect to database";
exit;
}
$result=mysql_select_db('reiki', $db);
if(!$result)
{
echo "Cannot Select database";
exit;
}

$query="select user from auth where user='$user' and pass=password('$pass')";
#$query="insert into auth values('$user',password('$pass'))";

$result = mysql_query($query, $db) or die('Query failed. '.mysql_error());

if(mysql_num_rows($result) > 0)
{
session_register('valid_user');
$valid_user = $user;
}

}

if(isset($valid_user))
{
echo "Welcome to the Admin Panel";

echo '<br><a href="check_new_form.php">Check New Entries</a>';

}
else
{
if(isset($user))
{
echo "Could Not log you In";
}
else
{
echo "You are not logged In";
}

?>
<form action='admin_login.php' method='post'>
<BR><BR><BR><table align='middle' valign='top' cellpadding='2' cellspacing='1' style='border-collapse: collapse'>
<tr>
<td border-right-style: none; border-right-width: medium; border-bottom-style: none; border-bottom-width: medium colspan='2'>
<p align='center'><font face='lucida sans unicode'>Administrator Login</font></td>
</tr>
<tr>
<td border-right-style: none; border-right-width: medium; border-bottom-style: none; border-bottom-width: medium><font face='lucida sans unicode'>Username:</font></td>
<td border-left-style: none; border-left-width: medium; border-bottom-style: none; border-bottom-width: medium><input type='text' name='user' size=20></td>
</tr>
<tr>
<td border-right-style: none; border-right-width: medium; border-bottom-style: none; border-bottom-width: medium><font face='lucida sans unicode'>Password:</font></td><td border-left-style: none; border-left-width: medium; border-bottom-style: none; border-bottom-width: medium><input type='password' name='pass' size=20></td>
</tr>

<tr>
<td colspan='2' align='center'><input type='submit' value='Log In'></td>

</tr>
</table>
</form>
<?php

}
?>
<p><a href="index.php">Home Page</a></p>
</body>
</html>

dreamcatcher

2:00 pm on Nov 14, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi xs2Manish,

Its probably down to register globals being OFF on your clients server.

Try using $_POST to access your variables.

$_POST['pass'];
$_POST['user'];

dc

Anyango

5:51 pm on Nov 14, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



yah i totally agree with dc, i think its exactly the same what he has pointed out.

xs2Manish

9:09 am on Nov 15, 2005 (gmt 0)

10+ Year Member



thanks dreamcather and anyango for your time.

but it is still not working.

i did what you said. first i removed the session part (though not recommended). then i placed the

$user = $_POST['user'];
$pass = $_POST['pass'];

in the begining of the page. but things still not moving.

actually i first did the change in the php.ini of my system to put register_globals and to off then tried what you had suggested thought the things went right on my system (as before) but it didnt do on the clients server.

i need some more time of yours.

thanks in advance