ES3Cloud.AddPostField() expected behaviour?

Discussion and help for Easy Save 3
Post Reply
Krakentanz
Posts: 5
Joined: Wed Jun 08, 2022 10:49 am

ES3Cloud.AddPostField() expected behaviour?

Post by Krakentanz »

Hey, just a quick question. Is an Instance of ES3Cloud expected to be re-used or set up fresh every time we use it?

I sent some additional Data to the php script via .AddPostField and was debugging on the apache side when i noticed the same data being sent over and over again on subsequent calls (even when calling cloud.AddPostField("sameKey","freshData") before transmitting. Upon inspection i found that there were multiple formData entries (same key, different values) piling up in the ES3Cloud instance. The php-script would always just retreive the first one of these, which would always be the first one ever added.

Is this expected behaviour? Would it make sense to add some SetPostField() method to ES3Cloud to overwrite the data? Or make overwriting the default behaviour? Or am i guilty of misconduct and should just create a fresh Instance of ES3Cloud before every call to the server? (Which is my current Solution, but i wanted to ask how it was intended to be used to avoid nasty overhead or stuff like that)

Thx as always for your support and replies! cheers
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: ES3Cloud.AddPostField() expected behaviour?

Post by Joel »

Hi there,

This is expected behaviour because it's often necessary to have multiple fields with the same name. For example, the server can access this as an array:

Code: Select all

es3Cloud.AddPOSTField ("brands[]", "CocaCola");
es3Cloud.AddPOSTField ("brands[]", "McDonalds");

Code: Select all

<?php
$brands = $_POST['brands'];
foreach ($brands as $brand) {
  echo $brand; // Outputs CocaColaMcDonalds
}
?>
In this case if you want different POST data to be sent you would create a new ES3Cloud object as you are currently doing :)

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Post Reply