Add an CURLOPT function
Add an CURLOPT function

Hello together,
First of all I want to say that these DataTables and the editor are totally brilliant tools, which relieved me a lot of programming work!
Now I have a very stable version with an adress database with overall 50k adress data. It works completely fine with column searching, fixing headers, formButtons, export and import functions and so on. Now I need a functionality with an additional external PHP CURLOPT function.
That means: Delete the selected contact in a row of the database and also delete the contact in an external system with only the delete button and one click.
Javascript adress.js
{
extend: "remove",
editor: editor,
text: "Delete contact",
className: 'btn-edit',
formButtons: [
{ text: 'Cancel', action: function () { this.close(); } },
{ text: 'Delete contact' ,
Insert code ........ something like this ???
action: function (e, dt, node, config) {
var emaildata = table.cell('.selected', 9).data();
External URL ('delete_contact.php?email=' + emaildata ..........
}
}
],
},
PHP-file delete_contact.php
if ($newsletter == "1") {
// delete contact in the newsletter system
$c = curl_init();
curl_setopt($c, CURLOPT_URL, "https://xxx.yyy.com/contact.php?email=$emaildata");
curl_exec($c);
$response_info = curl_getinfo($c);
curl_close($c);
echo "<p>Delete contact in both systems</p>";
} else {
echo "<p>Delete contact in database</p>";
}
How can I integrate the CURLOPT function? Is it possible to integrate it in the staff.php like this?
PHP-file staff.php
Field::inst( 'email' )
->validator( Validate::unique( ValidateOptions::inst()
->message( 'message' )
) )
if ($newsletter == "1") {
// delete contact in the newsletter system
$c = curl_init();
curl_setopt($c, CURLOPT_URL, "https://xxx.yyy.com/contact.php?email=$emaildata");
curl_exec($c);
$response_info = curl_getinfo($c);
.....
.....
Thanks in advance for any idea or short help.
Best regards
Mac
This question has an accepted answers - jump to answer
Answers
Thanks for the kind words. It sounds like you want to use a server-side event for that,
postRemove
should do the trick.Colin
Hello Colin,
thank you for your information and sorry for the late reply. That's absolutely the right trick. It's very easy to remove or edit another database with this function.
PHP-File: staff.php
Thanks a lot.....
Mac