This topic is locked
[SOLVED]

 Email function

11/6/2012 10:58:51 PM
PHPRunner General questions
P
phpcmk author

Hi guys,
I would need your help on the mail function. I need user to receive email base on the record that they created.
For example: User A create a new record and upon save, an email will be sent to User A. I am able to do a fixed email address but I need to do a dynamic one as my user could be over 100. In other word, User A create record 1(email sent to User A on record 1), User B create record 2(email sent to User B on record 2) etc
Below are the code with fixed email address:
-----------------------------------------------------------------------

Under Event tab > Add page > After record added

---------------------------------------------------------------------------

include "include_mail.php";
mysendmail('userA@yahoo.com','Title','halo, your data has been create');

---------------------------------------------------------------------------
Thanks in advance for the help

C
cgphp 11/7/2012

You can use the PHPrunner wrapper for mail() function: http://xlinesoft.com/phprunner/docs/runner_mail_function.htm

P
phpcmk author 11/8/2012

Hi,
I looked through the guides and it seems that email address (to) is pre-defined.
However, I need to send an email back to the creator who created their own records. Not a pre-defined email address.
Example: I have over 100+ users, and User A created new record A (upon clicking on Save, record A information will be sent to User A email address). If user B created new record B (upon clicking save, record B information will be sent to User B email address) etc.
I have been thinking if I created a database named "company" and 2 table named "staff" and "record".

Table staff contain columns ("userid", "password", "emailaddress")

Table record contain coumns ("creator")
So if User A login and create a new data, the column "creator" will capture the userid of User A (eg. $_SESSION["userid"])?

If creator==userid then it will retrive the email address in column "emailaddress" and sent to that user?
I am not really sure if this will work and how to go about writing the codes. Can anyone please help as I have been trying to solve this question past few days.
Thanks in advance for the help.

Sergey Kornilov admin 11/9/2012

You need to retrieve email address from the database.
If email field is a part of the record being added you can use $values["EmailFieldName"].
If email address is stored in the login table use AfterSuccessfulLogin event to save email address of current user in session variable:

$_SESSION["email"]=$data["emailaddress"]
Then in your code use $_SESSION["email"] instead of hardcoded email address.

P
phpcmk author 11/11/2012



You need to retrieve email address from the database.
If email field is a part of the record being added you can use $values["EmailFieldName"].
If email address is stored in the login table use AfterSuccessfulLogin event to save email address of current user in session variable:

$_SESSION["email"]=$data["emailaddress"]
Then in your code use $_SESSION["email"] instead of hardcoded email address.


Thanks, the problem is now solved.