Ralph3616 wrote:
- /* Add an $authorization[] row for each login/password pair you want to add: */
- $authorization[] = array('feldon', '123456', 'feldon @google.com');
- $authorization[] = array('ralphv', '1234only', 'ralph@lsvs.ca');
- $authorization[] = array('guest', '1234guest', 'guest@telus.net');
How (could I?)
- check to see if the email address exists, and if so
- send an email to that address with the user name and password on that row. As well as a brief message.. "xxxxxx xxxx xxxx" and a subject heading.
- if not, another error message about no match and to contact xxxxx@xxxxxxx.xxx
Would a second page (the result of a failed log in) have access to my login.php to find the desired information?
Could I make a file (data base?) on my server with that list?
Could this work?? Can any one show me how?
Thank you for your time.
Here's one way you could do it BUT it seems an awful lot of work if you have dozens of users - why are your usernames/passwords contained in arrays and not a database?
Anyway taking the 3 examples you have given above and assuming you have sent your user to a 'recover' username and password' page which has a form on it asking for the the email address of the user (give the input field the name of 'email_address' then on submit direct to the page below: It grabs the value of the email_address field from the form and then checks through the arrays to see if the email address exists. IF it does it sends the username and password to that email address.
I guess this is a low key security site so you have no need to md5 the passwords.
PLEASE NOTE I HAVE INSERTED AN 'X' IN THE EMAIL ADDRESSES WHICH NEEDS TO BR REMOVED. (SPAM)
<?php
$email_address = $_POST['email_address'];
$authorization[] = array('feldon', '123456', 'feldonX@google.com');
$authorization[] = array('ralphv', '1234only', 'ralphX@lsvs.ca');
$authorization[] = array('guest', '1234guest', 'guestX@telus.net');
if (in_array($email_address, $authorization[0])) {
$username = "feldon";
$password = "123456";
$email = "feldonX@google.com";
$matchFound = "success";
}
if (in_array($email_address, $authorization[1])) {
$username = "ralphv";
$password = "1234only";
$email = "ralphX@lsvs.ca";
$matchFound = "success";
}
if (in_array($email_address, $authorization[2])) {
$username = "guest";
$password = "1234guest";
$email = "guestX@telus.net";
$matchFound = "success";
}
if(isset($matchFound)) {
$to = $email_address;
// subject
$subject = "Your Username and Password";
$headers = "From: $email_address\r\n";
$headers .= "Reply-To: $email_address\r\n";
//build message
$message = "Username: $username\n\n";
$message .= "Password: $password\n\n";
mail($to, $subject, $message, $headers);
echo "We have sent you an email with your username and password";
}
else {
echo "No user exits with the email address provided";
}
?>