Hi all,
I am stuck trying to setup an Authentication with Session Control form
I keep getting the WARNING ERROR:Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/realest1/public_html/sellhome2.php on line 19
realest1_proppost is the database
and customers is the table
Could someone take a look at the code and tell me what I may be doing wrong?
<?
session_start();
if(!isset($HTTP_POST_VARS['login']) && !isset($HTTP_POST_VARS['password']))
{
$login = $HTTP_POST_VARS['login'];
$password = $HTTP_POST_VARS['password'];
$dbconnect = mysql_connect( 'localhost', 'MYDATABSE', 'MYDBPASSWORD' );
mysql_select_db ( 'realest1_proppost', $dbconnect);
$query = 'select (*) from customers '
."where login='$login' "
." and password=password('$password') ";
$result = mysql_query($query, $dbconnect);
if (mysql_num_rows($result) >0 )
{
$HTTP_SESSION_VARS['valid_user'] = $login;
}
}
?>
<?php
if( $login == 'login' && crypt($password, 'xx') == 'xxhaveaGreatDay' )
{
//OK passwords match
}
?>
<?php
$pictures = array( '/main_img/indexsplash.jpg' , '/main_img/indexsplash1.jpg' , '/main_img/indexsplash2.jpg' , '/main_img/indexsplash3.jpg' );
srand ((float)microtime()*1000000);
shuffle ($pictures);
?>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
<title>Welcome to *Real Estate Net Find* - List Your Home for Sale</title>
<META name="keywords" content="real estate,real-estate,home search,find a home,find a realtor,realtor, mortgage, homes for sale,home buying">
<META name="description" content="RealEstatenetfdind.com is premier provider of Califonia home listings, new West Coast homes for sale, finding a reputable REALTOR">
<link href="css/css_realestate.css" type="text/css" rel="stylesheet">
</head>
<body bgColor=#ffffff leftMargin=0 topMargin=0 MARGINHEIGHT="0" MARGINWIDTH="0">
<? include("includes/120x600bnr_ary.inc") ?><? include("includes/topnav03.php") ?>
<table border="0" cellpadding="0" cellspacing="0" width="754">
<tr height="6">
<td colspan="5" height="6"><img src="/main_img/6px_spacer.gif" width="6" height="6" border="0"></td>
</tr>
<tr>
<td width="6"><img src="/main_img/6px_spacer.gif" width="6" height="6" border="0"></td>
<td width="179" valign="top"><? include("includes/leftnav03.php") ?>
<table border="0" cellpadding="0" cellspacing="0" width="179" height="2">
<tr>
<td><img src="/main_img/2px_spacer.gif" width="2" height="2" border="0"></td>
</tr>
</table>
<? include("includes/leftnv_whatsnewincl.php") ?></td>
<td width="6"><img src="/main_img/6px_spacer.gif" width="6" height="6" border="0"></td>
<td bgcolor="#e1e7ee" valign="top">
<table border="0" cellpadding="0" cellspacing="0" width="557" bgcolor="#6d79ad" height="19">
<tr>
<td width="6"><img src="/main_img/6px_spacer.gif" width="6" height="6" border="0"></td>
<td><span class=pwhite>LIST YOUR HOME FOR SALE</span></td>
<td width="6"><img src="/main_img/6px_spacer.gif" width="6" height="6" border="0"></td>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="557">
<tr>
<td colspan="3"><img src="/main_img/home_plateau.jpg" width="557" height="42" border="0"></td>
</tr>
<tr>
<td colspan="3"><img src="/main_img/6px_spacer.gif" width="6" height="6" border="0"></td>
</tr>
<tr>
<td width="6"><img src="/main_img/6px_spacer.gif" width="6" height="6" border="0"></td>
<td width="545"><span class=psparkblu12><b>LIMITED TIME OFFER</b>: Since we are a brand new home search site entering the business, we wish to intially fill our database with many Southern California homes for sale to get our service started. All new home postings are absolutely free until we decide to switch to charging per listing. Real estate agents and private sellers take advantage of the FREE opportunity to list your property, today.</span><br>
<br>
<span class=psparkblu12><b>ABSOLUTELY NO OBLIGATION OR HIDDEN FEES!</b><br>
</span><br>
<span class=psparkblu12>Please login below, if your already have an account with us.</span></td>
<td width="6"><img src="/main_img/6px_spacer.gif" width="6" height="6" border="0"></td>
</tr>
<tr>
<td colspan="3"><img src="/main_img/6px_spacer.gif" width="6" height="6" border="0"></td>
</tr>
<tr>
<td colspan="3">
<HR WIDTH="545" SIZE=1 NOSHADE>
</td>
</tr>
<tr>
<td></td>
<td width="545" align="center">
<?
if (isset($HTTP_SESSION_VARS['valid_user']))
{
echo '<span class=psparkred12></br></span>';
echo '<span class=psparkred12>You are logged in as: '.$HTTP_SESSION_VARS['valid_user'].' </br></span>';
}
else
{
if (isset($userid))
{
echo '<span class=psparkred12></br></span>';
echo '<span class=psparkred12>* Invalid UserName and/or password. Please try again.</br></span>';
}
else
{
echo '<span class=psparkblu12></span>';
}
echo '<FORM ACTION="sellhome2.php" METHOD="POST">';
echo '<table border="0" cellpadding="0" cellspacing="0">';
echo '<tr>';
echo '<td><span class=psparkblu12>Login</span></td>';
echo '<td width="10" valign="middle"><img src="/main_img/10px_spacer.gif" width="10" height="10" border="0"></td>';
echo '<td><input type="text" name="login" size="12" tabindex="6"></td>';
echo '<td width="40"><img src="/main_img/10x40px_spacer.gif" width="40" height="10" border="0"></td>';
echo '<td><span class=psparkblu12>Password</span></td>';
echo '<td width="10" align="center"><img src="/main_img/10px_spacer.gif" width="10" height="10" border="0"></td>';
echo '<td><input type="text" name="password" size="12" tabindex="6"></td>';
echo '<td width="30" align="center"><img src="/main_img/10x30px_spacer.gif" width="30" height="10" border="0"></td>';
echo '<td><input name="Submit" type="submit" value="LOGIN"></td>';
echo '</tr>';
echo '</table>';
}
?>
<td></td>
</tr>
<tr height="6">
<td colspan="3" height="6"><img src="/main_img/6px_spacer.gif" width="6" height="6" border="0"></td>
</tr>
<tr>
<td colspan="3">
<HR WIDTH="545" SIZE=1 NOSHADE>
</td>
</tr>
</table>
</td>
<td width="6"><img src="/main_img/6px_spacer.gif" width="6" height="6" border="0"></td>
</tr>
<tr height="6">
<td colspan="5" height="6"><img src="/main_img/6px_spacer.gif" width="6" height="6" border="0"></td>
</tr>
</table>
<? include("includes/tipoftheday.inc") ?>
<? include("includes/botnav03.php") ?>
</body>
</html>
I am stuck trying to setup an Authentication with Session Control form
I keep getting the WARNING ERROR:Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/realest1/public_html/sellhome2.php on line 19
realest1_proppost is the database
and customers is the table
Could someone take a look at the code and tell me what I may be doing wrong?
<?
session_start();
if(!isset($HTTP_POST_VARS['login']) && !isset($HTTP_POST_VARS['password']))
{
$login = $HTTP_POST_VARS['login'];
$password = $HTTP_POST_VARS['password'];
$dbconnect = mysql_connect( 'localhost', 'MYDATABSE', 'MYDBPASSWORD' );
mysql_select_db ( 'realest1_proppost', $dbconnect);
$query = 'select (*) from customers '
."where login='$login' "
." and password=password('$password') ";
$result = mysql_query($query, $dbconnect);
if (mysql_num_rows($result) >0 )
{
$HTTP_SESSION_VARS['valid_user'] = $login;
}
}
?>
<?php
if( $login == 'login' && crypt($password, 'xx') == 'xxhaveaGreatDay' )
{
//OK passwords match
}
?>
<?php
$pictures = array( '/main_img/indexsplash.jpg' , '/main_img/indexsplash1.jpg' , '/main_img/indexsplash2.jpg' , '/main_img/indexsplash3.jpg' );
srand ((float)microtime()*1000000);
shuffle ($pictures);
?>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
<title>Welcome to *Real Estate Net Find* - List Your Home for Sale</title>
<META name="keywords" content="real estate,real-estate,home search,find a home,find a realtor,realtor, mortgage, homes for sale,home buying">
<META name="description" content="RealEstatenetfdind.com is premier provider of Califonia home listings, new West Coast homes for sale, finding a reputable REALTOR">
<link href="css/css_realestate.css" type="text/css" rel="stylesheet">
</head>
<body bgColor=#ffffff leftMargin=0 topMargin=0 MARGINHEIGHT="0" MARGINWIDTH="0">
<? include("includes/120x600bnr_ary.inc") ?><? include("includes/topnav03.php") ?>
<table border="0" cellpadding="0" cellspacing="0" width="754">
<tr height="6">
<td colspan="5" height="6"><img src="/main_img/6px_spacer.gif" width="6" height="6" border="0"></td>
</tr>
<tr>
<td width="6"><img src="/main_img/6px_spacer.gif" width="6" height="6" border="0"></td>
<td width="179" valign="top"><? include("includes/leftnav03.php") ?>
<table border="0" cellpadding="0" cellspacing="0" width="179" height="2">
<tr>
<td><img src="/main_img/2px_spacer.gif" width="2" height="2" border="0"></td>
</tr>
</table>
<? include("includes/leftnv_whatsnewincl.php") ?></td>
<td width="6"><img src="/main_img/6px_spacer.gif" width="6" height="6" border="0"></td>
<td bgcolor="#e1e7ee" valign="top">
<table border="0" cellpadding="0" cellspacing="0" width="557" bgcolor="#6d79ad" height="19">
<tr>
<td width="6"><img src="/main_img/6px_spacer.gif" width="6" height="6" border="0"></td>
<td><span class=pwhite>LIST YOUR HOME FOR SALE</span></td>
<td width="6"><img src="/main_img/6px_spacer.gif" width="6" height="6" border="0"></td>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="557">
<tr>
<td colspan="3"><img src="/main_img/home_plateau.jpg" width="557" height="42" border="0"></td>
</tr>
<tr>
<td colspan="3"><img src="/main_img/6px_spacer.gif" width="6" height="6" border="0"></td>
</tr>
<tr>
<td width="6"><img src="/main_img/6px_spacer.gif" width="6" height="6" border="0"></td>
<td width="545"><span class=psparkblu12><b>LIMITED TIME OFFER</b>: Since we are a brand new home search site entering the business, we wish to intially fill our database with many Southern California homes for sale to get our service started. All new home postings are absolutely free until we decide to switch to charging per listing. Real estate agents and private sellers take advantage of the FREE opportunity to list your property, today.</span><br>
<br>
<span class=psparkblu12><b>ABSOLUTELY NO OBLIGATION OR HIDDEN FEES!</b><br>
</span><br>
<span class=psparkblu12>Please login below, if your already have an account with us.</span></td>
<td width="6"><img src="/main_img/6px_spacer.gif" width="6" height="6" border="0"></td>
</tr>
<tr>
<td colspan="3"><img src="/main_img/6px_spacer.gif" width="6" height="6" border="0"></td>
</tr>
<tr>
<td colspan="3">
<HR WIDTH="545" SIZE=1 NOSHADE>
</td>
</tr>
<tr>
<td></td>
<td width="545" align="center">
<?
if (isset($HTTP_SESSION_VARS['valid_user']))
{
echo '<span class=psparkred12></br></span>';
echo '<span class=psparkred12>You are logged in as: '.$HTTP_SESSION_VARS['valid_user'].' </br></span>';
}
else
{
if (isset($userid))
{
echo '<span class=psparkred12></br></span>';
echo '<span class=psparkred12>* Invalid UserName and/or password. Please try again.</br></span>';
}
else
{
echo '<span class=psparkblu12></span>';
}
echo '<FORM ACTION="sellhome2.php" METHOD="POST">';
echo '<table border="0" cellpadding="0" cellspacing="0">';
echo '<tr>';
echo '<td><span class=psparkblu12>Login</span></td>';
echo '<td width="10" valign="middle"><img src="/main_img/10px_spacer.gif" width="10" height="10" border="0"></td>';
echo '<td><input type="text" name="login" size="12" tabindex="6"></td>';
echo '<td width="40"><img src="/main_img/10x40px_spacer.gif" width="40" height="10" border="0"></td>';
echo '<td><span class=psparkblu12>Password</span></td>';
echo '<td width="10" align="center"><img src="/main_img/10px_spacer.gif" width="10" height="10" border="0"></td>';
echo '<td><input type="text" name="password" size="12" tabindex="6"></td>';
echo '<td width="30" align="center"><img src="/main_img/10x30px_spacer.gif" width="30" height="10" border="0"></td>';
echo '<td><input name="Submit" type="submit" value="LOGIN"></td>';
echo '</tr>';
echo '</table>';
}
?>
<td></td>
</tr>
<tr height="6">
<td colspan="3" height="6"><img src="/main_img/6px_spacer.gif" width="6" height="6" border="0"></td>
</tr>
<tr>
<td colspan="3">
<HR WIDTH="545" SIZE=1 NOSHADE>
</td>
</tr>
</table>
</td>
<td width="6"><img src="/main_img/6px_spacer.gif" width="6" height="6" border="0"></td>
</tr>
<tr height="6">
<td colspan="5" height="6"><img src="/main_img/6px_spacer.gif" width="6" height="6" border="0"></td>
</tr>
</table>
<? include("includes/tipoftheday.inc") ?>
<? include("includes/botnav03.php") ?>
</body>
</html>