Submit pieces (After submit) php code with select field value not working

  • XaRz
  • Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 28
  • Thank you received: 0

XaRz created the topic: Submit pieces (After submit) php code with select field value not working

I'm trying :
1. To store the values of my form in a array:
2. Use curl function for pass the vars to another function.

I suspect I do something wrong in catching the values. Is the sentence for catching a Selected option of a Select right?(ff_getSubmit('Select')


Any help would be apreciated.

The code is like this:
$this->execPieceByName('ff_InitLib');
$url = 'url/function.php';
 

$fields = array(
'user' => urlencode('user'),
'parauladepas' => urlencode('passw'),
'nom' => urlencode(ff_getSubmit('nom')),
'mobil' => urlencode(ff_getSubmit('telf')),
'email' => urlencode(ff_getSubmit('email')),
'tipus_llicencia' => urlencode(ff_getSubmit('Select')),
'data_caducitat' => urlencode(ff_getSubmit('data'))
);

//url-ify the data for the POST
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string, '&');

//open connection
$ch = curl_init();

//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,  2);

//execute post
$result = curl_exec($ch);

//close connection
curl_close($ch);
?>  
#234684
  • Posts: 2561
  • Karma: 87
  • Thank you received: 344

mihaela replied the topic: Submit pieces (After submit) php code with select field value not working

Hello,

In End Submit pieces of the form you can fetch the submitted values with function:
ff_getSubmit('FIELDNAME');
so that is the correct command for catching a selected option, BUT in order to be able to use this function you need to put
$this -> execPieceByName('ff_InitLib');
as first line of code in your piece.

That is explained in this piece of documentation crosstec.org/en/support/online-documenta...ript-and-pieces.html .

Also, make sure to replace FIELDNAME with the Name of the filed and not the Title.

Let me know whether this resolves the problem.

Regards,

Mihaela
#234686
  • XaRz
  • Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 28
  • Thank you received: 0

XaRz replied the topic: Submit pieces (After submit) php code with select field value not working

You're right Mihaela, I missed this line in the last copy&paste.

One more thing.

There is a way to check if the code is working without checking the remote function ?

Thanks anyway
#234690
  • Posts: 2561
  • Karma: 87
  • Thank you received: 344

mihaela replied the topic: Submit pieces (After submit) php code with select field value not working

Hello again,

I'm glad that adding that line of code resolved the issue.

In this case, the best way to check if the code is working is to check the remote function since this is in End Submit.

Regards,

Mihaela
#234713
Moderators: ForumSupporttomeperica
Time to create page: 0.067 seconds

New Icon Packs Category!

Crosstec is now offering icon packs.

If you are a paying subscriber, icon packs are automatically added to your account.

Check out our icon packs page!

Live Support Chat Opened!

Join our Discord chat here to receive live support and talk directly to the team!

Summer Sale!

50% discount on all of our extension subscription plans, templates and icon packs!

Get Your Subscription Here

News and Updates

Get informed about new downloads, updates and more in our News and Updates newsletter.

All Extensions Subscription

Get 1 year access to all of our current and future products and 1 year of professional support -- 99 for just 49! (Summer Sale)

No support per domain or website installation limits! Includes all of our current and future Joomla!® extensions, Joomla!® templates for the duration of your membership. This means, by purchasing an All Extensions Subscription you'll have it all covered!

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!

Live Support Chat Opened!

Join our Discord chat here to receive live support and talk directly to the team!

Community Reward

Help us to create new extensions and plugins! With only $5 you help us a lot and get unlimited download access to all of our products, professional support and even more. Get your reward now!

Read More Here