forgot password - generer password
Hej eksperten. Jeg kunne godt bruge noget hjælp til at ændre min "forgot password" kode. Lige nu er den lavet sådan at den sender brugerens nuværende password og jeg vil gerne ha' den lavet om sådan at den generere et nyt password og tilsender brugeren. Og jeg kan ikke selv ændre koden så jeg håber at nogen kan hjælpe. :)if(isset($_POST['recover'])){
$form = 1;
$email = $db->EscapeString($_POST['email']);
$sql = $db->Query("SELECT username,email,password FROM `users` WHERE `email`='".$email."'");
$recover = $db->FetchArray($sql);
if($db->GetNumRows($sql) == 0){
$message = '<div class="msg error">We haven\'t found this email in our database!</div>';
}else{
$message = '<div class="msg success">Password was successfully sent to your email address!</div>';
function escapeAddr($addr) {
$check = preg_match('/(.*)<(.*)>/', $addr, $a);
if ($check) $addr = '=?UTF-8?B?'.base64_encode($a[1]).'?= <'.$a[2].'>';
return $addr;
}
function mail_utf8($to, $subject='Intet emne', $message='', $from='', $type='plain', $cc='', $bcc='')
{
$from = escapeAddr($from);
$header = 'From: '.$from.PHP_EOL
. 'MIME-Version: 1.0'.PHP_EOL
. 'Content-Type: text/'.$type.'; charset=UTF-8'.PHP_EOL
. 'X-Mailer: PHP/'.phpversion().PHP_EOL
. 'Content-Transfer-Encoding: 8bit'.PHP_EOL;
$header .= PHP_EOL;
return mail($to, '=?UTF-8?B?'.base64_encode($subject).'?=', $message, $header);
}
$msg = '
<html>
<head>
<style type="text/css">
<!--
@media only screen and (max-device-width: 480px) {#wrapper {width: 100% !important;} }
@media only screen and (max-device-width: 240px) {#wrapper {width: 100% !important;} }
-->
</style>
</head>
<body>
<center>
<div style="max-width:600px;display:block;margin: 20px auto 0px auto;" id="wrapper">
<div class="contentArea" id="contentArea1">
<table cellspacing="0" border="0" cellpadding="0" align="center" width="600" style="max-width:600px; width:600px; background-color: #000000;" id="headerTbl">
<tr>
<td align="center" valign="middle" width="600" style="line-height: 0">
<img border="0" src="http://member.wingisites.com/images/logo.png" style="display:block">
</td>
</tr>
</table>
<style type="text/css"><!-- #subheader a, .subheader a {color: #FF0000 !important;} --></style>
<table cellspacing="0" border="0" cellpadding="0" align="center" style="max-width:600px; width:600px;" id="contentTbl">
<tr>
<td align="left" valign="middle" width="600" style="padding: 10px 20px; background-color: #0000CC; color: #00FF33;" id="subheader" class="subheader">
klub wingisites det her det sker
</td>
</tr>
<tr>
<td style="background-color: #999999;">
<table cellspacing="0" border="0" style="max-width:600px; width:600px;" align="center" cellpadding="20" width="600">
<tr>
<td>
<style type="text/css"><!-- #innerTxt a, .innerTxt a {color: #66FF00 !important;} --></style>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="left" valign="top" height="300" id="innerTxt" class="innerTxt" style="color: #FF0000;">
<font size="5" color="red">Hej: '.$recover['username'].'<br>
<br>
Vi har modtaget anmodningen om gendannelse af adgangskoden.
<br>
Din adgangskode er: '.base64_decode($recover['password']).'<br>
<br>
Med venlig hilsen!<br>
klub wingisites</font>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
<table cellpadding="2" cellspacing="0" width="600" align="center">
<tr>
<td width="150" align="center">
</td>
<td width="450" align="center">
<font size="-1">
<br><br>
<b>klub wingisites</b><br>
Kenneth Hedelund
postboks 81
5700 Svendborg<br>
</font>
</td>
</tr>
</table>
</div>
</center>
<!-- HubSpot Email Marketing template: "Harvard" version: "1.2" timestamp: 1356449845 -->
</body></html>
';
mail_utf8($recover['email'], 'Your password', $msg, 'admin@wingisites.com', 'html');
$form = 1;
$email = $db->EscapeString($_POST['email']);
$sql = $db->Query("SELECT username,email,password FROM `users` WHERE `email`='".$email."'");
$recover = $db->FetchArray($sql);
if($db->GetNumRows($sql) == 0){
$message = '<div class="msg error">We haven\'t found this email in our database!</div>';
}else{
$message = '<div class="msg success">Password was successfully sent to your email address!</div>';
function escapeAddr($addr) {
$check = preg_match('/(.*)<(.*)>/', $addr, $a);
if ($check) $addr = '=?UTF-8?B?'.base64_encode($a[1]).'?= <'.$a[2].'>';
return $addr;
}
function mail_utf8($to, $subject='Intet emne', $message='', $from='', $type='plain', $cc='', $bcc='')
{
$from = escapeAddr($from);
$header = 'From: '.$from.PHP_EOL
. 'MIME-Version: 1.0'.PHP_EOL
. 'Content-Type: text/'.$type.'; charset=UTF-8'.PHP_EOL
. 'X-Mailer: PHP/'.phpversion().PHP_EOL
. 'Content-Transfer-Encoding: 8bit'.PHP_EOL;
$header .= PHP_EOL;
return mail($to, '=?UTF-8?B?'.base64_encode($subject).'?=', $message, $header);
}
$msg = '
<html>
<head>
<style type="text/css">
<!--
@media only screen and (max-device-width: 480px) {#wrapper {width: 100% !important;} }
@media only screen and (max-device-width: 240px) {#wrapper {width: 100% !important;} }
-->
</style>
</head>
<body>
<center>
<div style="max-width:600px;display:block;margin: 20px auto 0px auto;" id="wrapper">
<div class="contentArea" id="contentArea1">
<table cellspacing="0" border="0" cellpadding="0" align="center" width="600" style="max-width:600px; width:600px; background-color: #000000;" id="headerTbl">
<tr>
<td align="center" valign="middle" width="600" style="line-height: 0">
<img border="0" src="http://member.wingisites.com/images/logo.png" style="display:block">
</td>
</tr>
</table>
<style type="text/css"><!-- #subheader a, .subheader a {color: #FF0000 !important;} --></style>
<table cellspacing="0" border="0" cellpadding="0" align="center" style="max-width:600px; width:600px;" id="contentTbl">
<tr>
<td align="left" valign="middle" width="600" style="padding: 10px 20px; background-color: #0000CC; color: #00FF33;" id="subheader" class="subheader">
klub wingisites det her det sker
</td>
</tr>
<tr>
<td style="background-color: #999999;">
<table cellspacing="0" border="0" style="max-width:600px; width:600px;" align="center" cellpadding="20" width="600">
<tr>
<td>
<style type="text/css"><!-- #innerTxt a, .innerTxt a {color: #66FF00 !important;} --></style>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="left" valign="top" height="300" id="innerTxt" class="innerTxt" style="color: #FF0000;">
<font size="5" color="red">Hej: '.$recover['username'].'<br>
<br>
Vi har modtaget anmodningen om gendannelse af adgangskoden.
<br>
Din adgangskode er: '.base64_decode($recover['password']).'<br>
<br>
Med venlig hilsen!<br>
klub wingisites</font>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
<table cellpadding="2" cellspacing="0" width="600" align="center">
<tr>
<td width="150" align="center">
</td>
<td width="450" align="center">
<font size="-1">
<br><br>
<b>klub wingisites</b><br>
Kenneth Hedelund
postboks 81
5700 Svendborg<br>
</font>
</td>
</tr>
</table>
</div>
</center>
<!-- HubSpot Email Marketing template: "Harvard" version: "1.2" timestamp: 1356449845 -->
</body></html>
';
mail_utf8($recover['email'], 'Your password', $msg, 'admin@wingisites.com', 'html');
<form class="forgot_password<?=($form == 1 ? ' active' : '')?>" method="post">
<h3>Forgot Password</h3>
<div>
<label>Email:</label>
<input type="text" name="email" required="required" />
</div>
<div class="bottom">
<input type="submit" name="recover" value="Send reminder" />
<a href="#" rel="login" class="linkform">Suddenly remembered? Login here</a>
<a href="#" rel="register" class="linkform">You don't have an account? Register here</a>
<div class="clear"></div>
</div>
</form>
<h3>Forgot Password</h3>
<div>
<label>Email:</label>
<input type="text" name="email" required="required" />
</div>
<div class="bottom">
<input type="submit" name="recover" value="Send reminder" />
<a href="#" rel="login" class="linkform">Suddenly remembered? Login here</a>
<a href="#" rel="register" class="linkform">You don't have an account? Register here</a>
<div class="clear"></div>
</div>
</form>