problem with login
Posted: Mon Nov 14, 2005 3:17 am
twigletmac | Please use
twigletmac | Please use
Code: Select all
andCode: Select all
tags where approriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
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 thisCode: Select all
<?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>Code: Select all
andCode: Select all
tags where approriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]