Jump to content

Recommended Posts

ok i got this code so far i thought it was right but i keep getting the error cant do it. but the line seems ok. all the tables and rows are correct im baffled.

 


$mode = $HTTP_GET_VARS[\'mode\'];

if ($mode == "login"){

 $username = $HTTP_POST_VARS[\'username\'];

 $password = $HTTP_POST_VARS[\'password\'];

 $db=mysql_connect("localhost","","") or die ("cant connect"); 

 mysql_select_db("News",$db) or die ("cant change");

 $result=mysql_query("select * from users where name=\'$username\'",$db) or die ("cant do it");

 	while ($row=mysql_fetch_array($result)) {

   if ($row["password"]==$password) {

   	print("Successfully Logged In!<a href="default.php?"\'>Click Here</a>");

   	exit;

   }

 	}

}

Link to comment
https://forums.phpfreaks.com/topic/659-mysql-queries/
Share on other sites

Try this

 

$mode = $HTTP_GET_VARS[\'mode\']; 

  if ($mode == "login")

{ 

     $username = $HTTP_POST_VARS[\'username\']; 

     $password = $HTTP_POST_VARS[\'password\']; 

     $db=mysql_connect("localhost","","") or die ("cant connect"); 

     mysql_select_db("News",$db) or die ("cant change"); 

     $result=mysql_query("select * from users where name=\'$username\' and password=\'$password\'",$db) or die ("cant do it"); 

    $numrows = mysql_num_rows($result);



   	if ( $numrows > \'0\')

 {

 print("Successfully Logged In!<a href="default.php?"\'>Click Here</a>"); 

               exit; 



}



  } 

Link to comment
https://forums.phpfreaks.com/topic/659-mysql-queries/#findComment-2209
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.