Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[PHP]Invalid username/password

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
ElectroFusion
Grandmaster Cheater
Reputation: 0

Joined: 17 Dec 2006
Posts: 786

PostPosted: Fri Jul 04, 2008 9:40 am    Post subject: [PHP]Invalid username/password Reply with quote

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\wamp\www\login_do.php on line 8
username/password was incorrect.

I entered the right info.. heres my login_do script

<?php
#include "dbc.php";
session_start();
$username = $_POST['username'];
$password = $_POST['password'];
$sql="SELECT * FROM accounts WHERE username='$username' and password='$password'";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
if($count==1){
$_SESSION['username']=$username;
}else{
die ("username/password was incorrect.");
}

//Step 6
mysql_close();

//Step 7
echo "You have successfully logged in, please wait while we redirect you.";
header("Location: supertut.kicks-ass.org");
?>

_________________
qwerty147 wrote:

ghostonline wrote:

what world are you in?

bera

but i live in NZ
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Fri Jul 04, 2008 4:00 pm    Post subject: Reply with quote

Your SQL query looks a little off and I think there are a few more mistakes. Try this instead:

Code:
<?php

   include( 'dbc.php' );
   session_start();

   $username = $_POST[ 'username' ];
   $password = $_POST[ 'password' ];

   $sql = 'SELECT * FROM accounts WHERE username = ' . $username . ' AND password = ' . $password;
   $result = mysql_query( $sql );

   $count = mysql_num_rows( $result );

   //
   // Close the SQL connection here I guess if you dont
   // need it anymore after the above query..
   //

   if( $count == 1 )
   {
      $_SESSION[ 'username' ] = $username;
   }
   else
   {
      die( 'Username / password was incorrect.' );
   }
   
   //
   // If we got here, the login was successful..
   //

   //
   // Clear these to prevent hacking attempts since
   // we are done with them now..
   //
   unset( $username );
   unset( $password );

   // Redirect the user..
   header( "Location: somesite.com" );

?>

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
ElectroFusion
Grandmaster Cheater
Reputation: 0

Joined: 17 Dec 2006
Posts: 786

PostPosted: Fri Jul 04, 2008 10:06 pm    Post subject: Reply with quote

same stuff, but on line 12 now
_________________
qwerty147 wrote:

ghostonline wrote:

what world are you in?

bera

but i live in NZ
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

Joined: 09 May 2003
Posts: 25834
Location: The netherlands

PostPosted: Fri Jul 04, 2008 10:11 pm    Post subject: Reply with quote

or try this:
Code:

<?php

   include( 'dbc.php' );
   session_start();

   $username = $_POST[ 'username' ];
   $password = $_POST[ 'password' ];

   $sql = 'SELECT * FROM accounts WHERE username = ' . $username . ' AND password = ' . $password;
   $result = mysql_query( $sql );

   if (!$result)
   {
     die('Your query was wrong idiot. Make sure you have the tablename and fieldnames exactly as they should be. It is case sensitive. Also check you have a valid connection to the DB');
   }

   $count = mysql_num_rows( $result );

   //
   // Close the SQL connection here I guess if you dont
   // need it anymore after the above query..
   //

   if( $count == 1 )
   {
      $_SESSION[ 'username' ] = $username;
   }
   else
   {
      die( 'Username / password was incorrect.' );
   }
   
   //
   // If we got here, the login was successful..
   //

   //
   // Clear these to prevent hacking attempts since
   // we are done with them now..
   //
   unset( $username );
   unset( $password );

   // Redirect the user..
   header( "Location: somesite.com" );

?>

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
ElectroFusion
Grandmaster Cheater
Reputation: 0

Joined: 17 Dec 2006
Posts: 786

PostPosted: Fri Jul 04, 2008 10:20 pm    Post subject: Reply with quote

Dark Byte, your being an ass.

I modified the query to "SELECT * FROM accounts WHERE username = '.$username.' AND password = '.$password.'";

and it worked fine.

_________________
qwerty147 wrote:

ghostonline wrote:

what world are you in?

bera

but i live in NZ
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

Joined: 09 May 2003
Posts: 25834
Location: The netherlands

PostPosted: Fri Jul 04, 2008 10:26 pm    Post subject: Reply with quote

really?
And you're also getting the expected results?

try this:
"SELECT * FROM accounts WHERE username = '".$username."' AND password = '".$password."'";

Didn't come to mind at the first post they are string fields, so require a string as input.

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
ElectroFusion
Grandmaster Cheater
Reputation: 0

Joined: 17 Dec 2006
Posts: 786

PostPosted: Fri Jul 04, 2008 11:09 pm    Post subject: Reply with quote

Sir, if your going to be doing " like

mysql_query("");

and inside the script you used more "s like

mysql_query("SELECT * FROM `ass` WHERE `constipated` = ".$answer." AND `hastoshit` = 1");

you would put /".$answer./" instead. I replaced it with

mysql_query("SELECT * FROM `accounts` WHERE username = '$username' AND password = '$password'");

You don't need the periods. Mysql+php is weird, but I guess this is how they roll.

Now im trying cookies

Code:
<?php

   include( 'dbc.php' );
   session_start();

   $username = $_POST[ 'username' ];
   $password = $_POST[ 'password' ];
   #define idiot dumbass

   $sql = "SELECT * FROM accounts WHERE username = '$username' AND password = '$password'";
   $result = mysql_query( $sql );

   if (!$result)
   {
     die('Your query was wrong idiot. Make sure you have the tablename and fieldnames exactly as they should be. It is case sensitive. Also check you have a valid connection to the DB');
   }

   $count = mysql_num_rows( $result );

   if( $count == 1 )
   {
      setcookie(username, $username, time()+3600);
   }
   else
   {
      die( 'Username / password was incorrect.' );
   }

   unset( $username );
   unset( $password );

   header( "Location: http://supertut.kicks-ass.org" );

?>


error:
Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in C:\wamp\www\index.php on line 21

funny thing is, line 21 had commented stuff, and I deleted it. Still said the same stuff.

supposing it REALLY was being retarded and mean't here: setcookie(username, $username, time()+3600);

_________________
qwerty147 wrote:

ghostonline wrote:

what world are you in?

bera

but i live in NZ
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

Joined: 09 May 2003
Posts: 25834
Location: The netherlands

PostPosted: Fri Jul 04, 2008 11:27 pm    Post subject: Reply with quote

keep in mind that there's a difference between " and ' quotes
I think quotes with ' do dereference a string like $username into a string, but quotes with " not, or it may be the other way arround.

and for cookies, try : setcookie("username", $username, time()+3600);

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
ElectroFusion
Grandmaster Cheater
Reputation: 0

Joined: 17 Dec 2006
Posts: 786

PostPosted: Fri Jul 04, 2008 11:34 pm    Post subject: Reply with quote

when im doing stuff like echo "<div id="dkd"></div>"; I prefer to use ' so it doesn't interfear [cant spell, 1 in the morning]

Now im using sessions AGAIN.. nyway. When I go to index it pretends im logged off:

index.php

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>SuperTut</title>
<link href="styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="topbar">
<div id="text">
<?php
$my_t=getdate(date("U"));
echo("$my_t[weekday], $my_t[month] $my_t[mday], $my_t[year]");
?>
</div>
<div id="topbarlink">
<?php
$user = $_SESSION[ 'username' ];
if (!isset($user)){
echo '<a href="login.php">Login</a> | <a href="register.php">Register</a>';
}
if (isset($user)){
echo 'Hi.';
}
?>
</div>
</div>
<div id="links">
<div id="linkstext">
<a href="#">CSS</a> | <a href="#">Flash</a> | <a href="#">HTML</a> | <a href="#">Photoshop</a> | <a href="#">PHP</a> | <a href="#">Cinema 4D</a> | <a href="#">GIMP</a> | <a href="#">C++</a> | <a href="#">C#</a> | <a href="#">Visual Basic</a>
</div>
</div>
<div id="featured">
<div id="featitle">
<a href="#">Drawing HUGE boobs</a><br />
Photoshop >> Thursday, July 3, 2008<br />
</div>
<div id="feaby">
Submitted By:  <a href="#">lolcats.com</a><br />
</div>
<div id="fead">
Impress your friends, make your friends want to have your talent,<br />
tell them where to get this 'hawt' tutorial, and even a Counter Strike<br />
playing nerd can make nice boobs!
</div>
</div>
<br />
<div id="tut">
<div id="tuttitle">
<a href="#">Drawing HUGE boobs</a><br />
Photoshop >> Thursday, July 3, 2008<br />
</div>
<div id="tutby">
Submitted By:  <a href="#">lolcats.com</a><br />
</div>
<div id="tutd">
Impress your friends, make your friends want to have your talent,<br />
tell them where to get this 'hawt' tutorial, and even a Counter Strike<br />
playing nerd can make nice boobs!
</div>
</div><br />
<div id="tut">
<div id="tuttitle">
<a href="#">Drawing HUGE boobs</a><br />
Photoshop >> Thursday, July 3, 2008<br />
</div>
<div id="tutby">
Submitted By:  <a href="#">lolcats.com</a><br />
</div>
<div id="tutd">
Impress your friends, make your friends want to have your talent,<br />
tell them where to get this 'hawt' tutorial, and even a Counter Strike<br />
playing nerd can make nice boobs!
</div>
</div><br />
<div id="tut">
<div id="tuttitle">
<a href="#">Drawing HUGE boobs</a><br />
Photoshop >> Thursday, July 3, 2008<br />
</div>
<div id="tutby">
Submitted By:  <a href="#">lolcats.com</a><br />
</div>
<div id="tutd">
Impress your friends, make your friends want to have your talent,<br />
tell them where to get this 'hawt' tutorial, and even a Counter Strike<br />
playing nerd can make nice boobs!
</div>
</div><br />
<div id="tut">
<div id="tuttitle">
<a href="#">Drawing HUGE boobs</a><br />
Photoshop >> Thursday, July 3, 2008<br />
</div>
<div id="tutby">
Submitted By:  <a href="#">lolcats.com</a><br />
</div>
<div id="tutd">
Impress your friends, make your friends want to have your talent,<br />
tell them where to get this 'hawt' tutorial, and even a Counter Strike<br />
playing nerd can make nice boobs!
</div>
</div>
</body>
</html>


Login_do.php
Code:
<?php

   include( 'dbc.php' );
   session_start();

   $username = $_POST[ 'username' ];
   $password = $_POST[ 'password' ];

   $sql = "SELECT * FROM accounts WHERE username = '$username' AND password = '$password'";
   $result = mysql_query( $sql );

   if (!$result)
   {
     die('Your query was wrong idiot. Make sure you have the tablename and fieldnames exactly as they should be. It is case sensitive. Also check you have a valid connection to the DB');
   }

   $count = mysql_num_rows( $result );

   //
   // Close the SQL connection here I guess if you dont
   // need it anymore after the above query..
   //

   if( $count == 1 )
   {
      $_SESSION[ 'username' ] = $username;
   }
   else
   {
      die( 'Username / password was incorrect.' );
   }
   
   //
   // If we got here, the login was successful..
   //

   //
   // Clear these to prevent hacking attempts since
   // we are done with them now..
   //
   unset( $username );
   unset( $password );

   // Redirect the user..
   header( "Location: http://supertut.kicks-ass.org" );

?>


Or you could go on my site and register/login and see how it does.

_________________
qwerty147 wrote:

ghostonline wrote:

what world are you in?

bera

but i live in NZ
Back to top
View user's profile Send private message
STN
I post too much
Reputation: 43

Joined: 09 Nov 2005
Posts: 2676

PostPosted: Sat Jul 05, 2008 4:19 am    Post subject: Reply with quote

you have to include session_start(); at the top of pages where you want to use sessions.
_________________
Cheat Requests/Tables- Fearless Cheat Engine
https://fearlessrevolution.com
Back to top
View user's profile Send private message
ElectroFusion
Grandmaster Cheater
Reputation: 0

Joined: 17 Dec 2006
Posts: 786

PostPosted: Sat Jul 05, 2008 11:35 am    Post subject: Reply with quote

Thank you STN, will try now.
_________________
qwerty147 wrote:

ghostonline wrote:

what world are you in?

bera

but i live in NZ
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites