logo-dw

Go Back   Dreamweaver Club Forums > Hand Coders Forum > PHP
Register FAQ Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
Old 05-27-2012, 12:37 AM   #1
jaspindermukar
 
Join Date: Apr 2012
Posts: 13
Default login.php help

I am creating login form for first time and struck with following code:
PHP Code:
<?php 


session_start
(); 

$username $_POST['username']; 

$password $_POST['password']; 


if(
$username&&$password


    
$connect =mysql_connect("mysql10.000webhost.com","a9714196_jas","bawamano83")or die ("couldnt connect to database"); 
     
     
    
mysql_select_db("a9714196_jas") or die ("coulnt find database"); 
     
    
$query mysql_query("SELECT * FROM 'user' WHERE username = '$username'" ); 
     
    
$numrows mysql_num_rows ($query); 
      
     if(
$numrows !=0
      
     { 
          
         while(
$row =mysql_fetch_assoc($query)); 
         
         { 
              
             
$dbusername $row['username']; 
              
$dbpassword $row['password']; 
              
              
              
         } 
          
          
         if (
$username==$dbusername&&$password==$dbpassword
          
         { 
              
             echo 
"Login successful.<a href='membersarea.php'>Click here to enter the members area </a>"
              
         
$_SESSION ['username']=$dbusername
              
              
              
              
              
         } 
         else 
          
         echo
" Incorrect password"
          
     } 
     else  
    die(
" That username doesnot exist"); 
      
     
     
     


else 
      
     die(
"Please enter a username and password"); 





?>
The error message that I am getting is
Quote:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/a9714196/public_html/login.php on line 21
jaspindermukar is offline   Reply With Quote
Old 05-27-2012, 07:45 PM   #2
davidj
davidj's Avatar
 
Join Date: Sep 2005
Location: The Toon (newcastle upon Tyne)
Posts: 8,256
Default

Make sure your SQL is correct. Your tables are spelt correctly and are the correct case etc...

PHP Code:
SELECT FROM 'user' WHERE username '$username' 
__________________
Would you like to learn PHP from me? Check out -> www.codezenith.co.uk
davidj is offline   Reply With Quote
Old 05-28-2012, 01:59 AM   #3
edbr
edbr's Avatar
 
Join Date: Aug 2005
Location: Bali
Posts: 11,164
Default

seems not to like if($numrows !=0)
try


if ($numrows > 0) {
__________________
If you're happy and you know it shake your meds!
different style links examples

Flight / Hotel search
Free script download
Bali Villas
edbr is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 05:48 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Copyright 2006 DreamweaverClub.com