wachtwoord terug halen!
Hallo ik heb nu een script waar ik wil dat als je je wachtwoord vergeet dat je het terug kan vragen. Maar het lukt niet goed ik krijg een foutmelding:
Use of undefined constant MAIL_FROM - assumed 'MAIL_FROM' in ?:\??\??\????r\???\classes\system.php:515
hier de scriptj:
wat is hier nu fout ???????
Use of undefined constant MAIL_FROM - assumed 'MAIL_FROM' in ?:\??\??\????r\???\classes\system.php:515
hier de scriptj:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
//////////////////////////////////////////////////////////////////////
// Send forgot password email
//////////////////////////////////////////////////////////////////////
function sendForgotPasswordEmail($email) {
$email = addslashes($_POST["email"]);
if ($email == "")
die("Error: Empty e-mail address");
$query = "SELECT * FROM tb_empire WHERE email='$email'";
$rs = $this->DB->Execute($query);
if (!$rs->EOF) {
$newpassword = $this->generatePassword();
$activation_hash = md5(time(NULL) . $email);
$mail = new PHPMailer();
$mail->From = MAIL_FROM;
$mail->FromName = LANG_FORGOTPASSWORD_MAIL_SUBJECT;
$mail->Host = MAIL_SMTP;
$mail->Mailer = "smtp";
$mail->AddAddress($email);
$mail->Body = str_replace("{password}", $newpassword, TPL_MAIL_CONTENT_FORGETPASSWORD);
$mail->Subject = LANG_FORGOTPASSWORD_MAIL_SUBJECT;
if (!$mail->Send())
die("Error while sending email, retry or contact administrator");
$query = "UPDATE tb_empire SET password='" . md5($newpassword) . "' WHERE email='$email'";
$DB->Execute($query);
return true;
}
}
?>
//////////////////////////////////////////////////////////////////////
// Send forgot password email
//////////////////////////////////////////////////////////////////////
function sendForgotPasswordEmail($email) {
$email = addslashes($_POST["email"]);
if ($email == "")
die("Error: Empty e-mail address");
$query = "SELECT * FROM tb_empire WHERE email='$email'";
$rs = $this->DB->Execute($query);
if (!$rs->EOF) {
$newpassword = $this->generatePassword();
$activation_hash = md5(time(NULL) . $email);
$mail = new PHPMailer();
$mail->From = MAIL_FROM;
$mail->FromName = LANG_FORGOTPASSWORD_MAIL_SUBJECT;
$mail->Host = MAIL_SMTP;
$mail->Mailer = "smtp";
$mail->AddAddress($email);
$mail->Body = str_replace("{password}", $newpassword, TPL_MAIL_CONTENT_FORGETPASSWORD);
$mail->Subject = LANG_FORGOTPASSWORD_MAIL_SUBJECT;
if (!$mail->Send())
die("Error while sending email, retry or contact administrator");
$query = "UPDATE tb_empire SET password='" . md5($newpassword) . "' WHERE email='$email'";
$DB->Execute($query);
return true;
}
}
?>
wat is hier nu fout ???????
Gewijzigd op 01/01/1970 01:00:00 door M Rodrigo
MAIL_FROM is niet gedefineert, dus het heeft geen waarde.
Kunt u het uitleggen want ik heb dit script niet zelf geschreven en ik ben niet zo goed in PHP. ? wat moet er dan nog gebeuren
Gewijzigd op 01/01/1970 01:00:00 door M Rodrigo
Het is hier niet zo formeel dat we U gebruiken, dus zeg maar gewoon "je" ;-)
Je moet de functie define() hebben. Hiermee kun je een constante definiëren. In jouw geval:
define('MAIL_FROM', '[email protected]');
Je moet de functie define() hebben. Hiermee kun je een constante definiëren. In jouw geval:
define('MAIL_FROM', '[email protected]');
en nu krijg ik
Use of undefined constant MAIL_SMTP - assumed 'MAIL_SMTP' in ?:\???\???\?????\?????\classes\system.php
wat is er nu weer aan de hand ???
Use of undefined constant MAIL_SMTP - assumed 'MAIL_SMTP' in ?:\???\???\?????\?????\classes\system.php
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
//////////////////////////////////////////////////////////////////////
// Send forgot password email
//////////////////////////////////////////////////////////////////////
function sendForgotPasswordEmail($email) {
$email = addslashes($_POST["email"]);
if ($email == "")
die("Error: Empty e-mail address");
$query = "SELECT * FROM tb_empire WHERE email='$email'";
$rs = $this->DB->Execute($query);
if (!$rs->EOF) {
$newpassword = $this->generatePassword();
$activation_hash = md5(time(NULL) . $email);
$mail = new PHPMailer();
define('MAIL_FROM','[email protected]');
$mail->FromName = LANG_FORGOTPASSWORD_MAIL_SUBJECT;
$mail->Host = MAIL_SMTP;
$mail->Mailer = "smtp";
$mail->AddAddress($email);
$mail->Body = str_replace("{password}", $newpassword, TPL_MAIL_CONTENT_FORGETPASSWORD);
$mail->Subject = LANG_FORGOTPASSWORD_MAIL_SUBJECT;
if (!$mail->Send())
die("Error while sending email, retry or contact administrator");
$query = "UPDATE tb_empire SET password='" . md5($newpassword) . "' WHERE email='$email'";
$DB->Execute($query);
return true;
}
}
?>
//////////////////////////////////////////////////////////////////////
// Send forgot password email
//////////////////////////////////////////////////////////////////////
function sendForgotPasswordEmail($email) {
$email = addslashes($_POST["email"]);
if ($email == "")
die("Error: Empty e-mail address");
$query = "SELECT * FROM tb_empire WHERE email='$email'";
$rs = $this->DB->Execute($query);
if (!$rs->EOF) {
$newpassword = $this->generatePassword();
$activation_hash = md5(time(NULL) . $email);
$mail = new PHPMailer();
define('MAIL_FROM','[email protected]');
$mail->FromName = LANG_FORGOTPASSWORD_MAIL_SUBJECT;
$mail->Host = MAIL_SMTP;
$mail->Mailer = "smtp";
$mail->AddAddress($email);
$mail->Body = str_replace("{password}", $newpassword, TPL_MAIL_CONTENT_FORGETPASSWORD);
$mail->Subject = LANG_FORGOTPASSWORD_MAIL_SUBJECT;
if (!$mail->Send())
die("Error while sending email, retry or contact administrator");
$query = "UPDATE tb_empire SET password='" . md5($newpassword) . "' WHERE email='$email'";
$DB->Execute($query);
return true;
}
}
?>
wat is er nu weer aan de hand ???
Zelfde fout dus zelfde oplossing.
MAIL_SMTP is ook niet gedefineerd. Zelfde regel als Herjan alleen dan met MAIL_SMTP en waarde localhost (vermoed ik).
MAIL_SMTP is ook niet gedefineerd. Zelfde regel als Herjan alleen dan met MAIL_SMTP en waarde localhost (vermoed ik).
Precies hetzelfde, alleen nu bij MAIL_SMTP: Je gebruikt een constante die niet gedefinieerd is...
Sorry maar nu krijg ik weer een andere fout
Undefined variable: DB in ?:\???\???\????\??????\classes\system.php:36
(en bij define('mail_from',[email protected]) in plaats van de email moet toch staan $email omdat hij de emails van de database moet halen of heb ik het fout)
Undefined variable: DB in ?:\???\???\????\??????\classes\system.php:36
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
//////////////////////////////////////////////////////////////////////
// Send forgot password email
//////////////////////////////////////////////////////////////////////
function sendForgotPasswordEmail($email) {
$email = addslashes($_POST["email"]);
if ($email == "")
die("Error: Empty e-mail address");
$query = "SELECT * FROM tb_empire WHERE email='$email'";
$rs = $this->DB->Execute($query);
if (!$rs->EOF) {
$newpassword = $this->generatePassword();
$activation_hash = md5(time(NULL) . $email);
$mail = new PHPMailer();
define('MAIL_FROM','[email protected]');
$mail->FromName = LANG_FORGOTPASSWORD_MAIL_SUBJECT;
define('Host','localhost');
$mail->Mailer = "smtp";
$mail->AddAddress($email);
$mail->Body = str_replace("{password}", $newpassword, TPL_MAIL_CONTENT_FORGETPASSWORD);
$mail->Subject = LANG_FORGOTPASSWORD_MAIL_SUBJECT;
if (!$mail->Send())
die("Error while sending email, retry or contact administrator");
$query = "UPDATE tb_empire SET password='" . md5($newpassword) . "' WHERE email='$email'";
$DB->Execute($query);
return true;
}
}
?>
//////////////////////////////////////////////////////////////////////
// Send forgot password email
//////////////////////////////////////////////////////////////////////
function sendForgotPasswordEmail($email) {
$email = addslashes($_POST["email"]);
if ($email == "")
die("Error: Empty e-mail address");
$query = "SELECT * FROM tb_empire WHERE email='$email'";
$rs = $this->DB->Execute($query);
if (!$rs->EOF) {
$newpassword = $this->generatePassword();
$activation_hash = md5(time(NULL) . $email);
$mail = new PHPMailer();
define('MAIL_FROM','[email protected]');
$mail->FromName = LANG_FORGOTPASSWORD_MAIL_SUBJECT;
define('Host','localhost');
$mail->Mailer = "smtp";
$mail->AddAddress($email);
$mail->Body = str_replace("{password}", $newpassword, TPL_MAIL_CONTENT_FORGETPASSWORD);
$mail->Subject = LANG_FORGOTPASSWORD_MAIL_SUBJECT;
if (!$mail->Send())
die("Error while sending email, retry or contact administrator");
$query = "UPDATE tb_empire SET password='" . md5($newpassword) . "' WHERE email='$email'";
$DB->Execute($query);
return true;
}
}
?>
(en bij define('mail_from',[email protected]) in plaats van de email moet toch staan $email omdat hij de emails van de database moet halen of heb ik het fout)
De foutmelding lijkt me toch duidelijk genoeg: 'Undefined variabele: DB', er wordt zelfs een regelnummer bijgegeven!
Kortom, de variabele $DB bestaat niet. Waarschijnlijk heb je die dus nog nergens aangemaakt...
Kortom, de variabele $DB bestaat niet. Waarschijnlijk heb je die dus nog nergens aangemaakt...




