Follow us on Twitter!
Capitalism is an Island of wealth in a sea of poverty
Thursday, April 24, 2014
Navigation
Home
HellBoundHackers Main:
HellBoundHackers Find:
HellBoundHackers Information:
Learn
Communicate
Submit
Shop
Challenges
HellBoundHackers Exploit:
HellBoundHackers Programming:
HellBoundHackers Think:
HellBoundHackers Track:
HellBoundHackers Patch:
HellBoundHackers Other:
HellBoundHackers Need Help?
Other
Members Online
Total Online: 16
Guests Online: 14
Members Online: 2

Registered Members: 82889
Newest Member: Geriztul
Latest Articles
View Thread

HellBound Hackers | Computer General | Programming

Author

PHP Login


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 21-06-06 16:56
I'm trying to code a login for my site. It is an odd registration message whereby the register script send me an e-mail to check before I manually add the user to the database. I am having problems with mysql_result(). This is my login code:

Code

<?
$user=$_POST['username'];
$pass=$_POST['password'];
$encpass=md5($pass);

$mysqluser="mastergamer";
$mysqlpass="pass hidden";
$dbase="mastergamer";
mysql_connect(localhost, $user, $pass);
@mysql_select_db($dbase) or die( "Unable to select database");
$query="SELECT * FROM `users` WHERE user='$user' and pass='$encpass'";
$result=mysql_query($query);


$returneduser=mysql_result($result, "username");
$returnedpass=mysql_result($result, "password");
$returnedmail=mysql_result($result, "email");
 
mysql_close();

if($user==$returneduser && $encpass==$returnedpass)
{
echo "Now logged in as $user";
} else {
echo "Login error, please try again";
}
?>





I keep getting this error:

Code

Warning: mysql_result(): supplied argument is not a valid MySQL result resource.





What do I need to change in mysql_result() i order for it to work?


Author

RE: PHP Login


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 21-06-06 16:58
I would advise using mysql_fetch_array it works loads better.


Author

RE: PHP Login


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 21-06-06 17:01
Code
<?
$user=$_POST['username'];
$pass=$_POST['password'];
$encpass=md5($pass);

$mysqluser="mastergamer";
$mysqlpass="pass hidden";
$dbase="mastergamer";
mysql_connect(localhost, $user, $pass);
@mysql_select_db($dbase) or die( "Unable to select database");
$query="SELECT * FROM `users` WHERE user='$user' and pass='$encpass'";
$result=mysql_query($query);
$row=mysql_fetch_array($result);

$returneduser=($row['user']);
$returnedpass=($row['pass']);
$returnedmail=($row['email']);

mysql_close();

if($user==$returneduser && $encpass==$returnedpass)
{
echo "Now logged in as $user";
} else {
echo "Login error, please try again";
}
?>





Another thought, could it be that you are using "username" rather than "user"???




Edited by on 21-06-06 17:24
Author

RE: PHP Login


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 21-06-06 17:03
I changed the code to:
Code

<?
$user=$_POST['username'];
$pass=$_POST['password'];
$encpass=md5($pass);

$mysqluser="mastergamer";
$mysqlpass="hidden";
$dbase="mastergamer";
mysql_connect(localhost, $user, $pass);
@mysql_select_db($dbase) or die( "Unable to select database");
$query="SELECT * FROM `users` WHERE username='$user' and password='$encpass'";
$result=mysql_query($query);
$row=mysql_fetch_array($result);

$returneduser=mysql_result($row['username']);
$returnedpass=mysql_result($row['password']);
$returnedmail=mysql_result($row['email']);
 
mysql_close();

if($user==$returneduser && $encpass==$returnedpass)
{
echo "Now logged in as $user";
} else {
echo "Login error, please try again";
}
?>





and now it gives me the error:

Code
Wrong parameter count for mysql_result()





EDIT: Fixed it now, I changed $returneduser=mysql_result($row['username']); to
$returneduser=mysql_result($result,0,username); and now it works.

Thanks for your help :)




Edited by on 21-06-06 17:14
Author

RE: PHP Login

SySTeM
Member

Your avatar

Posts: 1524
Location: England, UK
Joined: 27.07.05
Rank:
HBH Guru
Posted on 21-06-06 19:32
Hehe, I exploited your register page PfftPfftPfft


img138.imageshack.us/img138/6527/sig2ak1.jpg
www.hellboundhackers.org/sig/r/2783.png

http://www.elites0ft.com/
Author

RE: PHP Login


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 21-06-06 21:20
Yes you did, but I patched that by only letting the same IP register once per hour.


Author

RE: PHP Login

SySTeM
Member

Your avatar

Posts: 1524
Location: England, UK
Joined: 27.07.05
Rank:
HBH Guru
Posted on 21-06-06 21:28
hehehe thanks god for cURL!


img138.imageshack.us/img138/6527/sig2ak1.jpg
www.hellboundhackers.org/sig/r/2783.png

http://www.elites0ft.com/
Author

RE: PHP Login


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 21-06-06 22:06
Yeah, that cURL is cool, I'm defiently going to learn that now Pfft


Author

RE: PHP Login


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 22-06-06 06:50
Yer, unfortunately my server doesn't have it.

Do you know any which do?


Author

RE: PHP Login


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 22-06-06 07:21
Here is a list from cURL's official website

* classicwebdevelopment.com phpinfo
* dreamhost.com
* flexwebhosting.nl
* fuitadnet.com
* godaddy.com
* henselhosting.com
* hostgator.com
* hytekhosting.com
* iquesthosting.com
* lunarpages.com
* lypha.com
* netvigour.com
* oneandone.co.uk
* schogini.com
* streamservice.nl

but I'm not too sure about free onesGrin