Zubrag.com
August 23, 2019, 03:56:05 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Reminder By Email - Finals Issue to get Working  (Read 6407 times)
gazza
Newbie
*
Posts: 9


« on: September 06, 2010, 01:52:46 PM »

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
');

?>

Logged
zubrag
Administrator
Hero Member
*****
Posts: 788


WWW
« Reply #1 on: September 07, 2010, 02:20:09 AM »

I think the problem is here
array($this->email, $this->LOGIN_INFORMATION[$this->email][1]),

you pass email, username, but no password. Should be something like this
array($this->email, $this->LOGIN_INFORMATION[$this->email][1], $this->LOGIN_INFORMATION[$this->email][NN]),

where NN should be 2 or 0 not sure
Logged
gazza
Newbie
*
Posts: 9


« Reply #2 on: September 07, 2010, 05:22:14 AM »

Many thanks Zubrag for you assistance, it now works.

Also thanks to others on this Forum who have posted various options which can be added.

This is a really great script, I've managed to add a few extra features despite being a relative novice when writing php
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC