Anothersledhead
Posts: 44
|
| Posted: 10/25/2004, 7:05 PM |
|
Does anyone have an example of a lost password script for PHP. For simplicity I am using the clients email address as their username.
Thanks
|
 |
 |
Philippe
|
| Posted: 10/27/2004, 2:01 AM |
|
you need 2 scripts: the first one on Cilch ( ask the password)
//Send Email @7-8015559D
global $Request;
$db = new clsDBConnection1();
ini_set("SMTP", "SMTP.idk-hannover.de");
$to = $Request->email->GetText();
$UserName=CCDLookUp("PLZ", "idk_mitgliedsbetriebe","Email = ".$db->ToSql($to,ccsText),$db);
$Password=CCDLookUp("Passwort", "idk_mitgliedsbetriebe", "Email =".$db->ToSql($to,ccsText),$db);
$subject = "Re: Passwort Anfrage";
$message = "Sie haben Ihre Zugangsdaten vergessen:\n"."Ihre PLZ ist: " .$UserName ."\n"."Ihr Passwort ist: " .$Password . "\n" ."\n";
$from = "info@idk-hannover.de";
ini_set("SMTP", "SMTP.idk-hannover.de");
$additional_headers = "From: $from\nReply-To: $from\nContent-Type: text/plain";
mail ($to, $subject, $message, $additional_headers);
ini_restore("SMTP");
//End Send Email
and the second one if the email is not in the database
global $Request;
// Write your own code here.
$db = new clsDBConnection1();
$db->query("SELECT * FROM idk_mitgliedsbetriebe WHERE Email=". $db->ToSQL($Request->email->GetValue(), ccsText));
$db->next_record();
// main_users is the name of the table that holds the users' emails data (user_email)
if($db->f("Email") == ""){
$Request->Errors->AddError("\n"."Die angegebene Mailadresse ist in der Datenbank nicht vorhanden!");
// the given email was not found in the data base --> return Error to the user
you need to go to the help of CCS and look to CCDlookup
Philippe
|
|
|
 |
klwillis
Posts: 428
|
| Posted: 10/27/2004, 8:02 AM |
|
Interesting ... I see you relay mail through a server
other than localhost. That can be very useful. 
Quote Philippe:
you need 2 scripts: the first one on Cilch ( ask the password)
//Send Email @7-8015559D
global $Request;
$db = new clsDBConnection1();
ini_set("SMTP", "SMTP.idk-hannover.de");
$to = $Request->email->GetText();
$UserName=CCDLookUp("PLZ", "idk_mitgliedsbetriebe","Email = ".$db->ToSql($to,ccsText),$db);
$Password=CCDLookUp("Passwort", "idk_mitgliedsbetriebe", "Email =".$db->ToSql($to,ccsText),$db);
$subject = "Re: Passwort Anfrage";
$message = "Sie haben Ihre Zugangsdaten vergessen:\n"."Ihre PLZ ist: " .$UserName ."\n"."Ihr Passwort ist: " .$Password . "\n" ."\n";
$from = "info@idk-hannover.de";
ini_set("SMTP", "SMTP.idk-hannover.de");
$additional_headers = "From: $from\nReply-To: $from\nContent-Type: text/plain";
mail ($to, $subject, $message, $additional_headers);
ini_restore("SMTP");
//End Send Email
and the second one if the email is not in the database
global $Request;
// Write your own code here.
$db = new clsDBConnection1();
$db->query("SELECT * FROM idk_mitgliedsbetriebe WHERE Email=". $db->ToSQL($Request->email->GetValue(), ccsText));
$db->next_record();
// main_users is the name of the table that holds the users' emails data (user_email)
if($db->f("Email") == ""){
$Request->Errors->AddError("\n"."Die angegebene Mailadresse ist in der Datenbank nicht vorhanden!");
// the given email was not found in the data base --> return Error to the user
you need to go to the help of CCS and look to CCDlookup
Philippe
_________________
Kevin Willis, VP/CIO
HealthCare Information Technology Specialist
http://www.nexushealthcare.com
"Fast - Convenient - Quality-Care"
Medical Software Consulting Services
Email : klwillis@nexushealthcare.com
Skype : klwillis2006 |
 |
 |
Tengel
Posts: 49
|
| Posted: 10/28/2004, 12:18 AM |
|
Another easy script is this one:
$DatabaseName = "database";
$DbHostName = "localhost";
$DbUserName = "user";
$DbPassWord = "password";
$userDatabase = "userdatabase";
$admin_email = "your@mail.com";
$inSendEmail = $sendEmail; // 1 if 2nd entry
?>
<table width='600' align='center'>
<tr valign='top'>
<td>
<H1>Passord reminder</H1>
</td>
</tr>
</table>
<table width='600' align='center'><tr><td>
<?
if ($inSendEmail == "") // ask for email
{
?>
<span class='detTxt'>Please add your email, and your password will be send to your email</span>
<form method="post" action="password.php">
<input type="hidden" value="1" name="sendEmail">
<span class="formTxt">Epost adresse: </span>
<input type="text" value="" name="email"><BR><BR>
<input type="submit" value="Send me password" name="Send me password">
</form>
<?
}
else // email password
{
mysql_connect($DbHostName,$DbUserName,$DbPassWord) or die("Failure to communicate with database") ;
mysql_select_db($DatabaseName) ;
$result = mysql_query("select passord FROM $userDatabase WHERE email='$email'");
while ($row = mysql_fetch_row($result)) {
$password = $row[0];
if ($password <> "") {
mail("$email", "$title Password reminder", "Hi.
your password is: $password","From: $admin_email") or die("Error. The program was unable to send email.");
echo "<span class='detTxt'>Your password have been send tou your email.</span>";
}
}
mysql_close();
if ($password == "") {
echo "<span class='detTxt'>No password have been found for this email, please try again.</span>";
}
}
echo "</td></tr></table><BR>";
----
_________________
---
Tengel |
 |
 |
Aless
|
| Posted: 11/07/2004, 2:03 PM |
|
Tengel your script is great but it doesnt work for me?? Can you help me?
|
|
|
 |
Tengel
Posts: 49
|
| Posted: 11/11/2004, 5:33 AM |
|
Sure, but it should work, but I did not translate this part correct
mysql_connect($DbHostName,$DbUserName,$DbPassWord) or die("Failure to communicate with database") ;
mysql_select_db($DatabaseName) ;
$result = mysql_query("select passord FROM $userDatabase WHERE email='$email'");
Passord should be password
_________________
---
Tengel |
 |
 |
Tengel
Posts: 49
|
| Posted: 11/11/2004, 5:35 AM |
|
Also remember that this should have the same name as your page
action="password.php
so if your page have another name, change this
_________________
---
Tengel |
 |
 |
gn1126
|
| Posted: 11/15/2004, 3:19 PM |
|
Hello Tengel
Your script looks easy and straight forward. however, i'm having some syntax problem. When I run it in IE, i keep getting:
Passord reminder
Please add your email, and your password will be send to your email
Epost adresse:
"") { mail("$email", "$title Password reminder", "Hi. your password is: $password","From: $admin_email") or die("Error. The program was unable to send email."); echo "Your password have been send tou your email."; } } mysql_close(); if ($password == "") { echo "No password have been found for this email, please try again."; } } echo "
";
Am I missing something? Please help?
|
|
|
 |
Tengel
Posts: 49
|
| Posted: 11/15/2004, 6:47 PM |
|
Well, I post it again, this one I have tested, and it is working. but you must change the info that are bold 
<?php
$DatabaseName = "yourdatabase ";
$DbHostName = "localhost";
$DbUserName = "username";
$DbPassWord = "yourpassword";
$userDatabase = "usertable";
$admin_email = "password@yourmail.com";
$inSendEmail = $sendEmail; // 1 if 2nd entry
?>
<table width='600' align='center'>
<tr valign='top'>
<td>
<H1>Password reminder</H1>
</td>
</tr>
</table>
<table width='600' align='center'><tr><td>
<?
if ($inSendEmail == "") // ask for email
{
?>
<span class='detTxt'>Please add your email, and your password will be send to your email</span>
<form method="post" action="yourpagename.php">
<input type="hidden" value="1" name="sendEmail">
<span class="formTxt">email: </span>
<input type="text" value="" name="email"><BR><BR>
<input type="submit" value="Send me password" name="Send me password">
</form>
<?
}
else // email password
{
mysql_connect($DbHostName,$DbUserName,$DbPassWord) or die("Failure to communicate with database") ;
mysql_select_db($DatabaseName) ;
$result = mysql_query("select password FROM $userDatabase WHERE email='$email'");
while ($row = mysql_fetch_row($result)) {
$password = $row[0];
if ($password <> "") {
mail("$email", "$title Password reminder", "Hi.
You or someone else have ask for your password
Your password is: $password","From: $admin_email") or die("Error. The program was unable to send email.");
echo "<span class='detTxt'>Your password have been send tou your email.</span>";
}
}
mysql_close();
if ($password == "") {
echo "<span class='detTxt'>No password have been found for this email, please try again.</span>";
}
}
echo "</td></tr></table><BR>";
?>
_________________
---
Tengel |
 |
 |
gn1126
|
| Posted: 11/15/2004, 9:03 PM |
|
Thanks a bunch, Tengel.
Works this time!
I guess you have to take newbies by the hand.
|
|
|
 |
|