login script help
Posted: Wed Oct 08, 2008 12:58 pm
I have a login script, that works great, using the old forum database for the forum software phpbb2.
The only thing that I can do, (know what to do) is to change the database info...
The only problem is, i get this error
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/gaogier/public_html/login.php on line 43
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/gaogier/public_html/login.php on line 44
I think, its because i need to edit more on the script, but what?
What should I change?
The only thing that I can do, (know what to do) is to change the database info...
The only problem is, i get this error
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/gaogier/public_html/login.php on line 43
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/gaogier/public_html/login.php on line 44
I think, its because i need to edit more on the script, but what?
What should I change?
Code: Select all
<?php
include ('diffhead.inc');
?><img src="images/homepage13.jpg" alt="" width="727" height="48"></td>
</tr>
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0" id="box4" class="box">
<tr>
<td class="content">
<center>
<?php
if(isset($_POST['submit'])){
if(empty($_POST['username'])){
$username = FALSE;
$message = '<table width=98% bgcolor=#353E48 class=logfail align=center><tr>
<td width=40 bgcolor=#353E48><img src=images/exclamation.gif></td>
<td align=left>
<B>Login Failed!</B> <BR>
No username entered.
<BR>Please Try again<br />
</table><br /><br />';
}else{
$username = mysql_real_escape_string($_POST['username']);
}
if(empty($_POST['password'])){
$password = FALSE;
$message1 = '<br /><table width=98% bgcolor=#353E48 class=logfail align=center><tr>
<td width=40><img src=images/exclamation.gif></td>
<td align=left>
<B>Login Failed!</B> <BR>
No password entered.
<BR>Please Try again<br />
</table><br /><br />';
}else{
$password1 = mysql_real_escape_string($_POST['password']);
$password = md5($password1);
}
//echo $password1 .' ' .$password. ' ' .$username;
if($username && $password){
require_once ('../mysql_connect1.php');
$query = "SELECT user_id, username, user_email, user_active, user_password, user_sitemod FROM phpbb_users WHERE username='$username' AND user_password='$password' AND user_sitemod = '1'";
$result = mysql_query ($query);
$row = mysql_fetch_array ($result);
if(mysql_num_rows($result) > 0)
{
$_SESSION['user_sitemod'] = $row['user_sitemod'];
$_SESSION['user_avatar'] = $row['user_avatar'];
$_SESSION['user_email'] = $row['user_email'];
$_SESSION['username'] = $row['username'];
$_SESSION['user_id'] = $row['user_id'];
//ob_end_clean();
// include('diffhead.inc');
include ('admin.inc');
echo '<p align="center">You\'ve logged in successfully.</p>';
include('difffooter.inc');
}else{
$message = '<table width=98% bgcolor=#353E48 class=logfail align=center><tr>
<td width=40><img src=images/exclamation.gif></td>
<td align=left>
<B>Login Failed!</B> <BR>
The login combination you entered was not found.
<BR>Please Try again<br />
</table><br /><br />';
}
}
}
echo '<font face=verdana size=2> <b>Login</b></font><br /><br />'.$message.$message1.'
Your browser must allow cookies in order to login.<br />';
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<table width=98% bgcolor=#353E48 class=blueborder align=center>
<tr>
<td width=40><img src=images/keylogin.gif></td>
<td align=right>
<B>Username:</B> <br /><br />
<B>Password:</B> <br /></td>
<td align=left>
<input type="text" name="username" size="10" maxlength="20" class="login" value ="<?php if (isset($_POST['username'])) echo $_POST['username']; ?>" /> <small><i>Please enter your username</small></i><br /><br />
<input type="password" name="password" size="20" maxlength="20" class="login"/> <small><i>Please enter your password</small></i></td></tr>
<tr><td width=40></td><td align="center"><input type="submit" name="submit" class="login" value="Login" /></td></tr>
</table><br /><br />
</form></center>
<?php
include ('difffooter.inc');
?>