CodeCharge Studio
search Register Login  

Visual Web Reporting

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

YesSoftware Forums -> CodeCharge Studio -> PHP

 email when data changed (Resolved)

Print topic Send  topic

Author Message
RoyBaird

Posts: 115
Posted: 01/28/2009, 2:21 PM

In PHP, how can you tell if something is changed? In asp/VB it is easy, but I can't tell when something is changed in PHP. I want to send an email to people based on what the new value was changed to.

Thanks,
_________________
Roy
View profile  Send private message
TonyReid


Posts: 159
Posted: 01/30/2009, 1:02 AM

There are lots of ways to do it. Some easy, some hard - what method would you consider easy in ASP/VB? if you provide that then I am sure someone here could translate it to PHP for you.

_________________
-----------
PHP/indy Game Developer - http://www.AbsoluteBreeze.co.uk
View profile  Send private message
Vasiliy

Posts: 378
Posted: 01/30/2009, 10:21 AM

First thing that comes to my mind - a language independent solution via triggers on DB level.
_________________
Vasiliy
View profile  Send private message
damian
Posted: 01/30/2009, 2:23 PM

the example packs include examples of how to email someone when status (data)
has changed - its just not that hard
i really dont understand how you build a language independant solution via
triggers on DB level - how can the DB send email? I may be wrong....

---------------------------------------
Sent from YesSoftware forum
http://forums.codecharge.com/
damian

Posts: 838
Posted: 01/30/2009, 2:23 PM

the example packs include examples of how to email someone when status (data) has changed - its just not that hard
i really dont understand how you build a language independant solution via triggers on DB level - how can the DB send email? I may be wrong....

_________________
if you found this post useful take the time to help someone else.... :)
View profile  Send private message
TonyReid


Posts: 159
Posted: 01/30/2009, 11:12 PM

Quote damian:
i really dont understand how you build a language independant solution via
triggers on DB level - how can the DB send email? I may be wrong....


MSSQL can send emails based on data changes using triggers... not sure if MySQL can do it though.


_________________
-----------
PHP/indy Game Developer - http://www.AbsoluteBreeze.co.uk
View profile  Send private message
damian

Posts: 838
Posted: 01/31/2009, 2:30 AM

http://forums.mysql.com/read.php?99,33635,170562#msg-170562

shows an example of using triggers in mysql 5 - it creates an email and outputs it to a file where you need a pickup to occur...

_________________
if you found this post useful take the time to help someone else.... :)
View profile  Send private message
RoyBaird

Posts: 115
Posted: 01/31/2009, 7:10 PM

thanks,
which example pack?
_________________
Roy
View profile  Send private message
damian

Posts: 838
Posted: 01/31/2009, 11:55 PM

try the task manager:
http://examples.codecharge.com/
it is included in code charge - create a new project - click on solutions tab and then task manager - im pretty sure that when you assign a task an email is sent to the lucky task recipient...
_________________
if you found this post useful take the time to help someone else.... :)
View profile  Send private message
RoyBaird

Posts: 115
Posted: 02/09/2009, 1:55 PM

the "tasl manager" example does not appear to send an email. I also tried to use a before show event to store the values of the controls, then check that value againt the current value to see if the value has changed and if yes, send an email. The problem is I am not a PHP hacker and I don't know the CCS syntax to reference the values to compare against. I can get the listbox.value, but no the "hold" value.

If I can get this piece figured out, then the whole application will work.

Thanks,
_________________
Roy
View profile  Send private message
codebang

Posts: 74
Posted: 02/10/2009, 3:32 AM

hey guys ,

did anyone solve this issue, cause im having the same problem, i need an email to be sent once the status is changed.

So did anyone reach to a solution .... the task manager does not provide any solutions.

Thank you,

Salah Hafiz Midhat
View profile  Send private message
damian

Posts: 838
Posted: 02/10/2009, 4:28 AM

i dont understand *exactly* what it is you are trying to do - but the i did the task manager example many moons ago and it worked - maybe its changed - i dont know - dont have time to retry it -
this is what i do -
i have a form - in this case a registration form -
i add custom code in the AfterExecuteInsert -

//Custom Code @46-2A29BDB7  
// -------------------------  
    // Send Email to Webmaster  
    // Send Email.  
	ini_set("SMTP", "localhost");  
	//Get HTML content from file  
	$to = 'webmaster@fqdn;  
	$content = "http://www.fqdn/SendRegisterRequest.php?s=".$Component->email->GetText()."&i=".mysql_insert_id();  
	$message = implode("", file($content));  
  
	//Prepare Mail  
	$subject = "Please Approve New Member";  
	$from = "Webmaster <webmaster@fqdn>";  
	$additional_headers = "From: $from\nReply-To: $from\nContent-Type: text/html";  
  
	//Send Mail  
	mail ($to, $subject, $message, $additional_headers,"-f webmaster@fqdn");  
	ini_restore("SMTP");  
// -------------------------  
//End Custom Code

key points to note:
fqdn -> fully qualified domain name
mysql_insert_id() -> returns the last entry into db by this session
$content = "http://www.fqdn/SendRegisterRequest.php?s=".$Component->email->GetText()."&i=".mysql_insert_id() -> i want to send something useful - in this case new users details and an option to approve or decline the user - so i create a page that has all this info and grabs the id from the url and i implode it so it reads the outout data into my email....
$message = implode("", file($content)) -> this is where i store the output page as email content

and then i send it
statements like "the task manager does not provide any solutions" doesnt inspire someone to go and provide you with a solution - there are answers there you gotta try it out

roy - there are prolly many ways to get the current db values and the news so you can send them in your email - one way would be to have a hidden field after each real field and set the hidden fields value in before show.

i am sure there are many different ways and some will most likely be much nicer than mine - but this works for me - hopefully you will find something of value here...

damian

_________________
if you found this post useful take the time to help someone else.... :)
View profile  Send private message
RoyBaird

Posts: 115
Posted: 02/10/2009, 6:27 AM

Thanks, the emailing is not the issue for me. There is an "action" that can be attached to an "event" and CCS prompts for the information it needs. My problem is I am not a PHP hacker and don't know the CCS syntax. In the BEFORE INSERT event, I want to compare a value that I stored with the "Store Control Value" action in the BEFORE SHOW event with the current value of the control. If the value was changed, based on what it is now, send an email. Currently, I receieve an email every time the page is submitted, so the conditon is "true", if the value was changed or not....

Here is the code...

//Save Control Value @54-1DF9371C
global $c_hold;
$c_hold = $Container->ListBox1->GetValue();
//End Save Control Value

//Research_ds_BeforeBuildInsert @2-B804F5EA
function Research_ds_BeforeBuildInsert(& $sender)
{
$Research_ds_BeforeBuildInsert = true;
$Component = & $sender;
$Container = & CCGetParentContainer($sender);
global $Research; //Compatibility
//End Research_ds_BeforeBuildInsert

//Custom Code @59-2A29BDB7
// -------------------------
global $Research;
global $t_hold;
global $c_hold;

$t_hold = $Component->ListBox1->GetText();
if($c_hold != $t_hold)
{
ini_set("SMTP", "mail.PSTmailsrvr.com");
$to = "roy.baird@presage-tech.com";
$subject = $Component->Name1->GetText();
$message = "Catalog Status has changed too";
$from = "roy.baird@presage-tech.com";
$charset = "Windows-1252";
$transferEncoding = "";
$additional_headers = "From: $from\nReply-To: $from\nContent-Type: text/plain; charset=$charset\nContent-Transfer-Encoding: $transferEncoding";
mail ($to, $subject, $message, $additional_headers);
ini_restore("SMTP");
}
// -------------------------
//End Custom Code

//Close Research_ds_BeforeBuildInsert @2-79C5883F
return $Research_ds_BeforeBuildInsert;
}
//End Close Research_ds_BeforeBuildInsert

Thanks,
_________________
Roy
View profile  Send private message
jjrjr1


Posts: 942
Posted: 02/10/2009, 8:03 AM

Hi

Here is another thought you might try.

Create a hidden field on your form lets say called changed_val

Then on the control you are checking for changed value add the client side event on change create a custom code action. (You might have to look at the HTML for the control to get the proper control name for use below)

document.formname.changed_val.value=document.formname.changed_control_name.value;


Then you can check the value of the changed value in the on validate action for the form

eg:
if($Container->changed_val->GetValue()){

... now in here you can set your e-mail contents to what ever based on the changed value in the control.

eg:

switch $Container->changed_val->GetValue();

Case x:
$mess = "1";
break;
Case .......

Your_Send_Mail_Function($mess);

}

Just a thought.
Let me know if that is useful

Have fun.
_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
View profile  Send private message
RoyBaird

Posts: 115
Posted: 02/16/2009, 2:48 PM

Thanks jjrjr... that is what I ended up doing, sort of. Since I had 3 different status's I wanted to test, I added 3 columns to the table and added a trigger on the update to make these columns stay in sync with each other. Then on the record, I added custom code in the 'on validate' event to test each pair and if different, send an email to the appropriate person. Not as elegant as I would like it to be, but it works and is supportable.

I would like to see an 'action' created by CCS for this process. I am sure a lot of other folks need to do the same thing.

Thanks to all for your help....

Mark this puppy RESOLVED....

_________________
Roy
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.

PHP Reports

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

Home   |    Search   |    Members   |    Register   |    Login


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