Experienced Elementalist
- Joined
- Dec 25, 2011
- Messages
- 278
- Reaction score
- 57
Don't get how to fix this
someone that could help me
Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!
Join Today!Have you queried the SQL code? lolUhm.. please help me i have an error :
Code:Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in H:\xampp\htdocs\forgotpassword.php on line 209 Error
This is really cool if i get it to work pleeease (also i use PhoenixPHP) sorry for bad english and please don't say im stupid because i use PhoenixPHP, i knoow !![]()
I know.. As I said, I'm more familiar with MySQL. I should learn MySQLi though.Wow, you're really bad at using mysqli ...
The code is damned messy.. Whispers to himself: Is this really secure?
Have you queried the SQL code? lol
I know.. As I said, I'm more familiar with MySQL. I should learn MySQLi though.
$stmt = $mysqli->prepare("INSERT INTO foo VALUES (?,?)");
$stmt->bind_param('ss','foo','bar');
Pretty sure he means learning how to use MySQLi, that's how I interpreted his comment anyway.How do you learn a library? Confusing...
How do you learn a library? Confusing...
By learning its functions.
![]()
Anyways thanks for this will use
but why dont you use html/utf8 in your mail headers?
$break = "\n";
$mime = new Mail_mime($break);
$mime->setHTMLBody($Body);
$body = $mime->get();
$headers = $mime->headers($headers);
I know.. As I said, I'm more familiar with MySQL. I should learn MySQLi though.
$stmt = $link->prepare('SELECT id FROM users WHERE username like ?');
$stmt->execute(array($username)); // being lazy
$theid = $stmt->fetchColumn();
// or fetch assoc like with mysql_fetch_assoc
$data = $stmt->fetch(PDO::FETCH_ASSOC);
// You can also bind parameters like this
$stmt->bindParam(1, $username, PDO::PARAM_STR); // define first ? as $username
// or set a var name
$stmt->bindParam(':username', $username, PDO::PARAM_STR); // just use :username in the query
$stmt->bindParam(1, $variable, PDO::PARAM_STR, 20);
$stmt->bindParam(1, $variable, PDO::PARAM_STR);
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\forgotpassword.php on line 209
Error
<?PHP
require_once("config.php");
// Configuration
$SiteLink = "http://example.com/forgotpassword";
// File MUST be named forgotpassword.php unless you edit the code
$LogoLink = "http://images.habbo.com/habboweb/63_1dc60c6d6ea6e089c6893ab4e0541ee0/1205/web-gallery/v2/images/habbologo_whiteR.gif";
$FromEmail = "from@lol.com";
if(isset($_GET['Reset']))
{
$arr = explode("-", $_GET['Reset']);
$Username = mysql_real_escape_string($arr[0]);
$query = mysql_query("SELECT NULL FROM `password_resets` WHERE `username` = '". $Username ."' AND `hash` = '". mysql_real_escape_string($_GET['Reset']) ."'");
if(mysql_num_rows($query) > 0)
{
$GetEmail = mysql_fetch_assoc(mysql_query("SELECT `mail` FROM `users` WHERE `username` = '". $Username ."'"));
echo $GetEmail['mail'];
GenerateNewPasswordEmail($Username, $GetEmail['mail']);
mysql_query("DELETE FROM `password_resets` WHERE `username` ='". $Username ."'");
echo "A new password has been sent to your email address.";
die;
}
else
{
echo "Invalid hash.";
echo "SELECT NULL FROM `password_resets` WHERE `username` = '". $Username ."' AND `hash` = '". mysql_real_escape_string($_GET['Reset']) ."'";
die;
}
}
function GenerateValidationEmail($username, $email, $hash)
{
global $SiteLink, $LogoLink;
SendMail($email, $username, '
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<style type="text/css">
</style>
</head>
<body>
<table width="98%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center">
<table border="0" cellpadding="0" cellspacing="0" width="595">
<tr>
<td align="left" style="border-bottom: 1px solid #aaaaaa;" height="70" valign="middle">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<img src="'. $LogoLink .'" alt="Habbo" width="110" height="40" style="margin-left: 12px; display: block;" />
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="left" style="border-bottom: 1px dashed #aaaaaa;" valign="middle">
<table style="margin-left: 12px; margin-right: 12px; padding: 0 0 10px 0; width: 100%;" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top">
<p style="font-family: Verdana,Arial,sans-serif; font-size: 20px; padding-top: 15px;">
Hello, '. $username .'
</p>
<p style="font-family: Verdana,Arial,sans-serif; font-size: 12px; padding-bottom: 5px;">
To change your password please click <a href="'. $SiteLink .'/account/password/reset/'. $hash .'">this link to reset your password</a>.
</p>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="left" style="border-bottom: 1px solid #aaaaaa;" height="100" valign="middle">
<table style="margin-left: 12px;" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="middle">
<table style="background-color: #51b708; height: 50px;" height="50px;" cellpadding="0" cellspacing="0">
<tr>
<td style="height: 100%; vertical-align:middle; border:solid 2px #000000" valign="middle">
<p style="font-family: Verdana,Arial,sans-serif; font-weight: bold; font-size: 18px; color:#ffffff; margin-top: 0; margin-bottom: 0;">
<a style="text-decoration: none; padding:15px 20px; color:#ffffff" href="'. $SiteLink .'/account/password/reset/'. $hash .'">
Reset my Habbo password
</a>
</p>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td valign="top" align="center">
<table style="font-family: Verdana,Arial,sans-serif; text-align: justify; font-size:11px; color:#aaaaaa; padding-top: 10px;padding-right: 10px;padding-left: 10px;padding-bottom: 10px; margin-top: 0pt;margin-right: 0pt;margin-left: 0pt;margin-bottom: 0pt;" border="0" cellpadding="0" cellspacing="0" width="595">
<tr>
<td height="8"><!-- Dummy --></td>
</tr>
<tr>
<td valign="top">
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>');
}
function GenerateNewPasswordEmail($username, $email)
{
global $SiteLink, $LogoLink;
$PlainPassword = substr (md5(uniqid(rand(),1)), 3, 10);
$HashedPassword = md5($PlainPassword);
mysql_query("UPDATE `users` SET `password` ='". $HashedPassword ."' WHERE `username` = '". $username ."'");
SendMail($email, $username, '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<style type="text/css">
</style>
</head>
<body>
<table width="98%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center">
<table border="0" cellpadding="0" cellspacing="0" width="595">
<tr>
<td align="left" style="border-bottom: 1px solid #aaaaaa;" height="70" valign="middle">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<img src="'. $LogoLink .'" alt="Habbo" width="110" height="40" style="margin-left: 12px; display: block;" />
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="left" style="border-bottom: 1px dashed #aaaaaa;" valign="middle">
<table style="margin-left: 12px; margin-right: 12px; padding: 0 0 10px 0; width: 100%;" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top">
<p style="font-family: Verdana,Arial,sans-serif; font-size: 20px; padding-top: 15px;">
Hello, '. $username .'
</p>
<p style="font-family: Verdana,Arial,sans-serif; font-size: 12px; padding-bottom: 5px;">
Your new password is: <b>'. $PlainPassword .'</b>
</p>
</td>
</tr>
</table>
</td>
</tr>
<tr>
</tr>
<tr>
<td valign="top" align="center">
<table style="font-family: Verdana,Arial,sans-serif; text-align: justify; font-size:11px; color:#aaaaaa; padding-top: 10px;padding-right: 10px;padding-left: 10px;padding-bottom: 10px; margin-top: 0pt;margin-right: 0pt;margin-left: 0pt;margin-bottom: 0pt;" border="0" cellpadding="0" cellspacing="0" width="595">
<tr>
<td height="8"><!-- Dummy --></td>
</tr>
<tr>
<td valign="top">
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>');
}
function SendMail($email, $username, $Body)
{
global $FromEmail;
require_once("Mail.php");
require_once('Mail/mime.php');
$headers = array('From' => $FromEmail, 'Subject' => "Password reset");
$break = "\n";
$mime = new Mail_mime($break);
$mime->setHTMLBody($Body);
$body = $mime->get();
$headers = $mime->headers($headers);
$mail = Mail::factory("mail");
$mail->send($email, $headers, $body);
}
if(isset($_POST['actionForgot']))
{
//
$query = mysql_query("SELECT * FROM `users` WHERE `username` = '". mysql_real_escape_string($_POST['forgottenpw-username']). "' AND `mail` = '". mysql_real_escape_string($_POST['forgottenpw-email']) ."'");
if(mysql_num_rows($query) > 0)
{
$hash = mysql_real_escape_string($_POST['forgottenpw-username']) ."-". md5(uniqid(rand())). "-". sha1(md5(uniqid(rand()))) . "-" . md5(uniqid(rand())). "-" . md5(rand()) ;
mysql_query("INSERT INTO `password_resets` (`username`, `hash`) VALUES ('". mysql_real_escape_string($_POST['forgottenpw-username']) ."', '". $hash."')") or die("INSERT INTO `password_resets` (`username`, `hash`) VALUES ('". mysql_real_escape_string($_POST['forgottenpw-username']) ."', '". mysql_real_escape_string($_POST['forgottenpw-username']) ."-". md5(uniqid(rand()))."'");
GenerateValidationEmail(mysql_real_escape_string($_POST['forgottenpw-username']), mysql_real_escape_string($_POST['forgottenpw-email']), $hash);
}
else echo "Error";
die;
}
?><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<title>Hotelname ~ Home </title>
<link rel="stylesheet" href="http://images.habbo.com/habboweb/63_1dc60c6d6ea6e089c6893ab4e0541ee0/1205/web-gallery/static/styles/common.css" type="text/css">
<link rel="stylesheet" href="http://images.habbo.com/habboweb/63_1dc60c6d6ea6e089c6893ab4e0541ee0/1205/web-gallery/static/styles/process.css" type="text/css">
<body id="landing" class="process-template">
<div id="overlay"></div>
<div id="container">
<div class="cb process-template-box clearfix"><div class="bt"><div></div></div><div class="i1"><div class="i2"><div class="i3">
<div id="content">
<div id="header" class="clearfix">
<h1><a href="index.php"></a></h1>
</div><style type="text/css">
div.left-column { float: left; width: 50% }
div.right-column { float: right; width: 49% }
label { display: block }
input { width: 98% }
input.process-button { width: auto; float: right }
</style>
<div id="process-content">
<div class="left-column">
<div class="cb clearfix"><div class="bt"><div></div></div><div class="i1"><div class="i2"><div class="i3">
<div class="rounded-container"><div style="background-color: rgb(255, 255, 255); "><div style="margin: 0px 1px; height: 1px; overflow: hidden; background-color: rgb(255, 255, 255); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(253, 150, 87); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 108, 20); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 98, 4); "></div></div></div></div><div style="margin: 0px; height: 1px; overflow: hidden; background-color: rgb(255, 255, 255); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 108, 20); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 98, 4); "></div></div></div><div style="margin: 0px; height: 1px; overflow: hidden; background-color: rgb(253, 150, 87); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 98, 4); "></div></div><div style="margin: 0px; height: 1px; overflow: hidden; background-color: rgb(252, 108, 20); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 98, 4); "></div></div></div><h2 class="title rounded-done">Forgotten Your Password?</h2><div style="background-color: rgb(255, 255, 255); "><div style="margin: 0px; height: 1px; overflow: hidden; background-color: rgb(252, 108, 20); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 98, 4); "></div></div><div style="margin: 0px; height: 1px; overflow: hidden; background-color: rgb(253, 150, 87); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 98, 4); "></div></div><div style="margin: 0px; height: 1px; overflow: hidden; background-color: rgb(255, 255, 255); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 108, 20); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 98, 4); "></div></div></div><div style="margin: 0px 1px; height: 1px; overflow: hidden; background-color: rgb(255, 255, 255); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(253, 150, 87); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 108, 20); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 98, 4); "></div></div></div></div></div></div>
<div class="box-content">
<p>Don't panic! Please enter your account information below and we'll send you an email telling you how to reset your password.</p>
<div class="clear"></div>
<form method="post" action="forgotpassword.php" id="forgottenpw-form">
<p>
<label for="forgottenpw-username">Username</label>
<input type="text" name="forgottenpw-username" id="forgottenpw-username" value="">
</p>
<p>
<label for="forgottenpw-email">Email address</label>
<input type="text" name="forgottenpw-email" id="forgottenpw-email" value="">
</p>
<p>
<input type="submit" value="Request information" name="actionForgot" class="submit process-button" id="forgottenpw-submit">
</p>
<input type="hidden" value="default" name="origin">
</form>
</div>
</div></div></div><div class="bb"><div></div></div></div>
</div>
<div class="right-column">
<div class="cb clearfix"><div class="bt"><div></div></div><div class="i1"><div class="i2"><div class="i3">
<div class="rounded-container"><div style="background-color: rgb(255, 255, 255); "><div style="margin: 0px 1px; height: 1px; overflow: hidden; background-color: rgb(255, 255, 255); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(253, 150, 87); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 108, 20); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 98, 4); "></div></div></div></div><div style="margin: 0px; height: 1px; overflow: hidden; background-color: rgb(255, 255, 255); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 108, 20); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 98, 4); "></div></div></div><div style="margin: 0px; height: 1px; overflow: hidden; background-color: rgb(253, 150, 87); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 98, 4); "></div></div><div style="margin: 0px; height: 1px; overflow: hidden; background-color: rgb(252, 108, 20); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 98, 4); "></div></div></div><h2 class="title rounded-done">False Alarm!</h2><div style="background-color: rgb(255, 255, 255); "><div style="margin: 0px; height: 1px; overflow: hidden; background-color: rgb(252, 108, 20); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 98, 4); "></div></div><div style="margin: 0px; height: 1px; overflow: hidden; background-color: rgb(253, 150, 87); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 98, 4); "></div></div><div style="margin: 0px; height: 1px; overflow: hidden; background-color: rgb(255, 255, 255); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 108, 20); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 98, 4); "></div></div></div><div style="margin: 0px 1px; height: 1px; overflow: hidden; background-color: rgb(255, 255, 255); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(253, 150, 87); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 108, 20); "><div style="height: 1px; overflow: hidden; margin: 0px 1px; background-color: rgb(252, 98, 4); "></div></div></div></div></div></div>
<div class="box-content">
<p>If you have remembered your password, or if you just came here by accident, click the link below to return to the homepage.</p>
<p><a href="index.php">Back to homepage</a></p>
</div>
</div></div></div><div class="bb"><div></div></div></div>
</div>
<!--[if lt IE 7]>
<script type="text/javascript">
Pngfix.doPngImageFix();
</script>
<![endif]-->
<div id="footer">
<p><a href="index.php" target="_self">Homepage</a> </p>
<p>HABBO is a registered trademark of Sulake Corporation. All rights reserved to their respective owner(s).</p>
</div> </div>
</div>
</div></div></div><div class="bb"><div></div></div></div>
</div>
</body></html>