Forums

send data from CF to push notification

adam M 26 Oct, 2020
How to pass data from text field using php ? ... here is my problem
I use CF7
Easy form with two pages.
- on the first page there is a text field: label: Text24 , Field Name: tekst
- on the second page I use php module with such a code :

<?php
curl_setopt_array($ch = curl_init(), array(
CURLOPT_URL => "https://api.pushover.net/1/messages.json",
CURLOPT_POSTFIELDS => array(
"token" => "????",
"user" => "????",
"message" => "test",
),
CURLOPT_SAFE_UPLOAD => true,
CURLOPT_RETURNTRANSFER => true,
));
curl_exec($ch);
curl_close($ch);
?>


I used ???? to mark my data🙂
This is working great🙂 The form is sending me a push notification to my phone🙂

But I would like to send instead of "test" a data obtained from first page from field tekst.
I found that in php I can not use {data:tekst} ... so I found a few inspirations but NONE is working😟

I found :
$this->data("tekst", "default value");

so I put that in line 2
and changed
"message" => "test",
to
"message" => $this,

but it is not working😟 .... the second page is not loading so I can not even see debug data.

Can someone help me how to fix this ?
😀
Max_admin 26 Oct, 2020
1 Likes
it should be:
"message" => $this->data("tekst", "default value"),
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
adam M 26 Oct, 2020
1 Likes
:) it's working !!!! Thanks

I must learn the syntax of php😟 ... still much to do for me😉
adam M 26 Oct, 2020
works ...hence the option "default value" is not working

If the field tekst is left empty ..the php code do not send a notification at all😟

if I put something to the tekst field - this is working fine
adam M 29 Oct, 2020
"default value" ... what is it ?
a variable ?
a form value ?
a variable defined in php code ?

Maybe someone can explain this to me🙂
Asking - because I can not make it work in the code posted above.
Max_admin 03 Nov, 2020
make the field "tekst" required and it will not be empty!
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
adam M 03 Nov, 2020
:)
partially solved🙂
... but sometimes field "tekst" can be empty .... then I will not receive a notification I would like to get, for example a statement like this : " field 'tekst' was left empty "

OK, anyway . it works 🙂
but here on the forum we still have no explanation how to use that second part of the statement :

"message" => $this->data("tekst", "default value"),
..
Max_admin 04 Nov, 2020
Answer
1 Likes
the 2nd part of the data() function is correct, that will send a "default value" string if the field tekst is "not available", not if it's empty, if you want an alternative when it's empty then use this:
"message" => ($this->data("tekst") ? $this->data("tekst") : "default"),
but again, just make the field required!
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
You need to login to be able to post a reply.