CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 Retrieve Password Script

Print topic Send  topic

Author Message
PeterJ


Posts: 90
Posted: 03/22/2004, 4:06 AM

Where can I find a script, similar to the one on this forum, that enables users to retrieve their password by email?

Thanks

Peter
View profile  Send private message
Helmut

Posts: 9
Posted: 03/22/2004, 6:20 AM

Build an additional record form name=request on your Login Page, put there one TextBox email, enable validation and put the following custom code as on Validate event:
//snip
//Send Email @17-87BC55DD
global $Request;
$db = new clsDBmaillist();// <- your Database Connection

$to = $Request->email->GetText();
$loginName=CCDLookUp("user_login", "users","email= ".CCToSql($to,ccsText),$db);
$Password=CCDLookUp("user_password", "users", "email= ".CCToSql($to,ccsText),$db);

$subject = "Ihre Login Daten";
$message = "Sie veranlassten die erneute Zusendung Ihrer Login Daten:\n"."Benutzername/Login ist: " .$loginName ."\n"."Ihr Password ist: " .$Password . "\n" ."\n";
$from = "admin@anywhere.com";
$additional_headers = "From: $from\nReply-To: $from\nContent-Type: text/plain";
mail ($to, $subject, $message, $additional_headers);
//End Send Email
//snip

Helmut
View profile  Send private message
PeterJ


Posts: 90
Posted: 03/22/2004, 8:18 AM

Helmut

Many thanks, I was very confused with the CCDLookUp but this has helped.

thank you again

Peter
View profile  Send private message
Helmut

Posts: 9
Posted: 03/22/2004, 8:42 AM

Peter,

I just take an look to my code, I see I make an error, the code I post before must be in the button on_click event and I have another part in the validate event:
function Request_OnValidate()
{
$Request_OnValidate = true;
//End Request_OnValidate

//Custom Code @16-EE8B51DD
// -------------------------
global $Request;
// Write your own code here.
$db = new clsDBmaillist();
$db->query("SELECT * FROM users WHERE email=\"".$Request->email->Value."\"");
$db->next_record();

// users is the name of the table that holds the users' emails data (email)
if($db->f("email") == ""){
$Request->Errors->AddError("\n"."Diese eMail Adresse ist nicht gespeichert");
// the given email was not found in the data base --> return Error to the user
}else{
$Request->Errors->AddError("\n"."Die Daten wurden Ihnen per eMail zugeschickt");
}


// -------------------------
//End Custom Code

//Close Request_OnValidate @11-DD23907C
return $Request_OnValidate;
}
//End Close Request_OnValidate
View profile  Send private message
PeterJ


Posts: 90
Posted: 03/22/2004, 12:35 PM

Hello Helmut

Thank you again. I have that in place now and all is well

Peter
View profile  Send private message
kirchaj
Posted: 04/11/2005, 10:51 AM

I am trying to get this script to work with a postgres database and keep coming up with errors. Here is the error


Warning: pg_exec(): Query failed: ERROR: parser: zero-length delimited identifier at or near """" at character 33 . in /var/www/html/accttest/db_pgsql.php on line 98
Database error: Invalid SQL: SELECT * FROM users WHERE email=""
PostgreSQL Error: 1 (ERROR: parser: zero-length delimited identifier at or near """" at character 33 )
Session halted.

It looks like I am not getting anything from the form to query against. Here is a copy of the code


Here is my on-click event

//page_request_Button_Update_OnClick @16-9E9F4B1E
function page_request_Button_Update_OnClick()
{
var result;
//End page_request_Button_Update_OnClick

//Custom Code @17-2A29BDB7
// -------------------------
// Write your own code here.
// -------------------------
global $request;
$db = new clsDBedtechaccount();
// Write your own code here.
$to = $request->emailaddr->GetValue();
$loginname=CCDlookUp("login", "users","email= ".CCToSql($to,ccsText),$db);
$password=CCDLookUp("password", "users", "email= ".CCToSql($to,ccsText),$db);

$subject = "Password Reminder";
$message = "Sie veranlassten die erneute Zusendung Ihrer Login Daten:\n"."Benutzername/Login ist: " .$loginname ."\n"."Ihr Password ist: " .$password . "\n" ."\n";
$from = "edtech@wku.edu";
$additional_headers = "From: $from\nReply-To: $from\nContent-Type: text/plain";
mail ($to, $subject, $message, $additional_headers);
//End Send Email

//End Custom Code

//Close page_request_Button_Update_OnClick @16-BC33A33A
return result;
}
//End Close page_request_Button_Update_OnClick


Here is my validate event code

//request_OnValidate @12-BFAC7F10
function request_OnValidate()
{
$request_OnValidate = true;
//End request_OnValidate

//Custom Code @18-002688B1
// -------------------------
global $request;
// Write your own code here.
$db = new clsDBedtechaccount();
$db->query("SELECT * FROM users WHERE email=\"".$Request->email->Value."\"");
$db->next_record();

// users is the name of the table that holds the users' emails data (email)
if($db->f("email") == ""){
$Request->Errors->AddError("\n"."Diese eMail Adresse ist nicht gespeichert");
// the given email was not found in the data base --> return Error to the user
}else{
$Request->Errors->AddError("\n"."Die Daten wurden Ihnen per eMail zugeschickt");
}
// -------------------------
//End Custom Code

//Close request_OnValidate @12-C7DFC077
return $request_OnValidate;


Any Help you could give would be greatly appreciated.

TK


Nicole

Posts: 586
Posted: 04/12/2005, 2:14 AM

Hello,
You cannot get a field value using $form_name->field_name->GetValue() or $form_name->ds->field_name->GetValue() in button’s onClick event. Value property is empty at that moment. You’d rather use CCGetParam() or CCGetFromPost() function to obtain field’s value

_________________
Regards,
Nicole
View profile  Send private message
antoine
Posted: 04/13/2005, 4:15 AM

hello ,

i paste this code in a form but when clicking on the button i get this error, Fatal error: Call to a member function query() on a non-object in H:\www-data\password\test_events.php on line 22

What am i doing wrong?

Antoine
Nicole

Posts: 586
Posted: 04/13/2005, 4:57 AM

Antoine,
Make sure that you’re using valid database connection name, it is spelled correctly and connection exists in the project

_________________
Regards,
Nicole
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.