I'm trying to create a reminder by Email Address Form, I've almost got it working however I have one minor problem which I hope someone can help
I receive a reminder email however the email sends the Email Address and Login but not the Password
The scripts I have edited are as follows
reminderemail.php
<?php
####################################################################
# Password Protect Avanced :: Email Reminder Form - v.1.1
####################################################################
# Visit http://www.zubrag.com/scripts/ for documentation and updates
####################################################################
// load settings
include_once('settings.php');
class zubrag_reminderemail_form {
function zubrag_reminderemail_form() {
$this->error = '';
$this->email = '';
}
function parse_user_input() {
$this->email = isset($_POST['access_email']) ? $_POST['access_email'] : '';
// remove suspicious characters
$remove_chars = array("\n","\r", "\r\n", '"', "'", '&','<','>',',','/', '\\');
// convert to lowercase
$this->email = strtolower(str_replace($remove_chars, '', $this->email));
}
function showReminderPasswordProtect() {
include('reminderemail_header.php');
include('reminderemail_form.php');
include('reminderemail_footer.php');
}
function validate_user_input() {
// email validation
if ($this->email === '') {
$this->error = "Email Address Incorrect or Not Registered";
return false;
}
}
function load_users_list() {
// list of users
$users = @file(USERS_LIST_FILE);
if ($users) {
// remove php "die" statement (hackers protection)
unset($users[2]);
}
// prepare users list
$this->LOGIN_INFORMATION = array();
foreach ($users as $user) {
$u = explode(',',$user);
$this->LOGIN_INFORMATION[trim($u[2])] = array(trim($u[1]), trim($u[0]));
}
}
function validate_user() {
// check if user exists
foreach($this->LOGIN_INFORMATION as $key => $value) {
if ($key == $this->email) {
return true;
}
}
$this->error = "Email Address $this->email does not exist";
return false;
}
// send reminder
function send_email() {
// additional email headers
$headers = 'From: ' . REMINDEREMAIL_EMAIL . "\r\n" .
'Reply-To: ' . REMINDEREMAIL_EMAIL . "\r\n" .
'X-Mailer: PHP mailer';
$email = $this->email;
$res = @mail(
$email, // to
REMINDEREMAIL_SUBJECT, // subject
str_replace(
array('%email%', '%login%', '%password%'),
array($this->email, $this->LOGIN_INFORMATION[$this->email][1]),
REMINDEREMAIL_MESSAGE
),
$headers
);
if (!$res) $this->error = "Could not send reminder. Please try again";
}
function redirect() {
header('Location: ' . REMINDER_THANKS_URL);
exit();
}
}
$reminder_form_instance = new zubrag_reminderemail_form();
if (isset($_POST['access_email'])) {
while (true) {
$reminder_form_instance->parse_user_input();
if ($reminder_form_instance->error) break;
$reminder_form_instance->validate_user_input();
if ($reminder_form_instance->error) break;
$reminder_form_instance->load_users_list();
if ($reminder_form_instance->error) break;
$reminder_form_instance->validate_user();
if ($reminder_form_instance->error) break;
$reminder_form_instance->send_email();
if ($reminder_form_instance->error) break;
$reminder_form_instance->redirect();
break;
}
if ($reminder_form_instance->error) $reminder_form_instance->showReminderPasswordProtect();
}
else {
// show signup form
$reminder_form_instance->showReminderPasswordProtect();
}
?>
settings.php
Added the following to the bottom
/ Email will be user as "From" email
define('REMINDEREMAIL_EMAIL', 'secretary@stroudskittles.co.uk');
// Subject for reminder email
define('REMINDEREMAIL_SUBJECT', 'Password Reminder');
// User will be redirected to this page after submit
define('REMINDEREMAIL_THANKS_URL', 'http://www.stroudskittles.co.uk/reminder.html');
define('REMINDEREMAIL_MESSAGE', '
Hello
Your Login Information is as follows:
Email Address: %email%
User Name: %login%
Password: %password%
Regards
Stroud and District Skittle League
');
?>