Form Update

QuestionsForm Update
Rheal asked 4 years ago

I have a function set up to send an email out when a Grid column is updated.

There are only 3 fields that I need to update in the SQL table, but there are 9 fields I need to send in the email.
I have found that to include the fields that I am not updating they have to be in the form to get the values passed to the email function.

The grid data is from a View and I am updating a Table which does not contain all the fields that I need to send in the email.

So here is the problem. One of these fields is "email_Address" If I include this field in the form and run the update, the email function works and sends the value in the email. But that field in not in my update table so I get an error when updating the record.

How can I include fields in the form but set them up so the form will not try to pass the value to the SQL table for update as they do not exist in the table.
(There is more then one field I need to do this with, just using one for simplicity)

$e["on_update"] = array("update_request", null, true);
$g->set_events($e);

function update_request($data)
{
$to = "EMAIL TO HERE"; // this is your Email address you are sending too.
$from = "EMAIL FROM HERE";//$_POST['email']; // this is the sender's Email address
$subject = "PUT THE SUBJECT HERE";
$Request_ID = $data["params"]["Request_ID"];
$begins = $data["params"]["Request_Approved"];
$location = $data["params"]["fk_Approved_Location"];
$instructor = $data["params"]["Prime_Instructor1"];
$student = $data["params"]["StuName"];
$stuemail = $data["params"]["email_Address"];
$approved_date = $data["params"]["Request_Approved"];
$dennied_date = $data["params"]["Request_Denied"];
$notes = $data["params"]["Req_Notes"];

$message = "
<html>
<head>
<title>Approval/Dennied</title>
</head>
<body>

Request Information: nn<br /><br />
Student: $student nn<br />
Location Information: nn<br /><br />
Preferred Location: $location nn<br />
Date Information: nn<br /><br />
Approved_Date: $approved_date nn<br />
Dennied_Date: $dennied_date nn<br />
Notes: $notes nn<br />
Inst1_Email: $inst1 nn<br />
Request_ID: $request_IDnn<br />
Student_Email: $stuemail nn
</body>
</html>
";

$_POST['message'];
$headers = 'MIME-Version: 1.0' . "rn";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "rn";
$headers .= "From:" . $from;
mail($to,$subject,$message,$headers);

};

1 Answers
Rheal answered 4 years ago

I found the solution.

Change the value in this to false.
$e["on_update"] = array("update_request", null, false); //Change from "true" to "false"

Doing so will stop the grid from doing the update.
This allows me to place a SQL Update statement within my Mail function.
This way I can place all the fields I want in the form but only update the valid fields in my table.

$e["on_update"] = array("update_request", null, false); //Change this to false
$g->set_events($e);

function update_request($data)
{
$to = "EMAIL TO HERE"; // this is your Email address you are sending too.
$from = "EMAIL FROM HERE";//$_POST['email']; // this is the sender's Email address
$subject = "PUT THE SUBJECT HERE";
$Request_ID = $data["params"]["Request_ID"];
$begins = $data["params"]["Request_Approved"];
$location = $data["params"]["fk_Approved_Location"];
$instructor = $data["params"]["Prime_Instructor1"];
$student = $data["params"]["StuName"];
$stuemail = $data["params"]["email_Address"];
$approved_date = $data["params"]["Request_Approved"];
$dennied_date = $data["params"]["Request_Denied"];
$notes = $data["params"]["Req_Notes"];

$message = "
<html>
<head>
<title>Approval/Dennied</title>
</head>
<body>

Request Information: nn<br /><br />
Student: $student nn<br />
Location Information: nn<br /><br />
Preferred Location: $location nn<br />
Date Information: nn<br /><br />
Approved_Date: $approved_date nn<br />
Dennied_Date: $dennied_date nn<br />
Notes: $notes nn<br />
Inst1_Email: $inst1 nn<br />
Request_ID: $request_IDnn<br />
Student_Email: $stuemail nn
</body>
</html>
";

//PUT MY SQL UPDATE STATEMENT HERE UPDATING ONLY THE VALID FIELDS

$_POST['message'];
$headers = 'MIME-Version: 1.0' . "rn";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "rn";
$headers .= "From:" . $from;
mail($to,$subject,$message,$headers);

};

Your Answer

16 + 11 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?