function generatePassword ($length = 8)
{
// start with a blank password
$password = "";
// define possible characters
$possible = "0123456789bcdfghjkmnpqrstvwxyz";
// set up a counter
$i = 0;
// add random characters to $password until $length is reached
while ($i < $length) {
// pick a random character from the possible ones
$char = substr($possible, mt_rand(0, strlen($possible)-1), 1);
// we don't want this character if it's already in the password
if (!strstr($password, $char)) {
$password .= $char;
$i++;
}
}
// done!
return $password;
}
$is_ideasbank = 1;
$title="i2mOnline :: Ideas Bank";
$menu_right = "../templates/right_ideasbank2.php";
include("../templates/top.php"); ?>
I FORGOT MY PASSWORD
mysql_connect($host, $bdduser,$bddpasswd) or die("error connecting to the server");
mysql_select_db($db) or die("error connecting to the database");
if(isset($_POST['Submit']))
{
$email = strtolower($_POST['entered_username']);
if(strlen($email) > 0)
{
$query = "SELECT id,firstname FROM px_registered_members2 WHERE email='$email'";
$result = mysql_query($query);
if(mysql_num_rows($result) > 0)
{
$row = mysql_fetch_object($result);
$firstname = $row->firstname;
$newpassword = generatePassword();
$md5password = md5($newpassword);
$datetime = date("Y-m-d H:i:s");
$query = "UPDATE px_registered_members2 SET newpassword='$md5password',newpassdatetime='$datetime' WHERE email='$email'";
$url = "http://www.i2monline.com/ideasbank/confirmpassword_expert.php?email=".stripslashes($email)."&hash=".$md5password.base64_encode($datetime);
$result = mysql_query($query);
if($result)
{
$submitted = 1;
$subject = "i2m Online Password Reset Initiated";
$message = "Dear ".$firstname.",
You have just requested a new password for your account.
Your password is shown below:
----------------------------
Username: ".$email."
Password: ".$newpassword ."
----------------------------
To reset your password please click on the link below:
".$url."
If you did not request your password to be reset and you have received this email, please ignore this email. Don't worry, neither your email address, nor this link have been sent to anyone else.
If you have any questions, please don't hesitate to contact us at customer.support@i2monline.com
Yours sincerely.
--
i2m Online - Administrator
www.i2mOnline.com";
$headers = "From: i2mOnline@i2mOnline.com\n" .
'X-Mailer: PHP/' . phpversion() . "\n" .
"MIME-Version: 1.0\n";
// "Content-Type: text/html; charset=utf-8\n" .
// "Content-Transfer-Encoding: 8bit\n\n";
// Send
$to = stripslashes($email);
$response = mail($to, $subject, $message, $headers);
?>
i2m Online has sent an email to your address.
To reset your password:
- Go to the “i2mOnline.com Password Reset Initiated” email sent
to the address you provided.
- Click on the link in the email to reset your password.
- You can then login into i2m Online from http://www.i2monline.com/ideasbank/login.php.
If you do not receive the email, please email us at support@i2monline.com
}
else
{
$error = 3;
}
}
else
{
$error = 1;
?>
This email is not registered.
}
}
}
if($submitted < 1 && $error < 2)
{
?>
To retrieve a new password, please enter your email.
}
mysql_close();
?>
include("../templates/bottom.php"); ?>