I’m having problems with obtaining a value that starts as URL parameter.
I have a form on a page that is accessed by a url that has a parameter - product_id. I have used ‘Session storage manager to save this value in a Browser session. ( See screen shot )
I need to use this value in the page that the form re-directs to. I need to use the value in a Server action. My understanding is I need to define the session… BUT WHERE?. I see I can define it from Globals/input/$_SESSION, but I can also define a session from API/input/$_SESSION. ( See screen shots )
A client-side session and a server-side session are different sessions. To get the value from the client side to the server, you need to use the POST or GET method, and only then you can use this value on the server side.
Now when the page is submitted and re-directed to the next page. I can add the session storage manager to the page and add the same variable productID and use it in the page. I’ve tried this and it works fine.
But I need to get this value and use it in the condition in the Database query…
I think you are really trying to overcomplicate things here.
Is all what you need to do - send the ?product=1 value on form submit to your server action?
You don’t need sessions for that.
All you need is a hidden field in your form, which gets a dynamic value of dmx-bind:value="query.product" and it will post the value of the query parameter named product to your server action.
Yes there’s two pages. You might remember I setup a multi-step form which is an application form. This page is directed to by the url rtm-application-form.php?productID=1 The productID value is variable depending on different types of application we have. The value relates to the item previously created in this DB table. so productID = item_id
When this form is submitted it re-directs to the account set-up page which will be user-registration.
The details from this form gets inserted into this table. where I also need to insert the productID value into
You can use session variable to pass the value after insert on page 1 then do redirect to page 2.
On the page 2 just use the session variable value to filter your server action using a GET variable.
Sound easy in theory but where I’m struggling is performing this in wappler. I’m just not fully understanding the interface. It’s not straight forward for us mere beginners.
@Teodor@Mr.Rubi i’m pulling my hair out with this.
So this is what i’ve got…
Hidden field in form on first page: <input type="hidden" name="product_id" id="product-id" value="" dmx-bind:value="query.productID">
I then go to the API action in the second page and the GET variable product_id i’m using the input name from the hidden field. Is this correct?
I then go to server connect properties where I need to pick the value for the input parameter . There’s two possible options here… Query/productID or Session Storage manager/data/productID… I’ve tried both and neither work!!
Assuming a get the above value correct eventually…
So then I got to the data query on and use the GET value in the Condition.
Steven, I think you've mixed up two different approaches a bit.
In your case, you can not use the hidden input at all.
So, on your server side, everything looks right from the video.
What do you need to do on the client side:
First you have to repeat the steps that you have already done before:
Then you go to the second page and make the following settings there:
The data must be used from Session Storage manager/data/ProductID. You write above that it doesn't work. Perhaps because you didn't perform the setings specified in step 1 beforehand?
The logic of the work should be like this. When you go to the first page on the client side, the value is stored in the ProductID session variable. Then, when you go to the second page and the session variable takes this value and is used as an input parameter for Server Connect. On the server, this parameter is used to filter the database query.
I must be missing something really stupid here @Mr.Rubi. So changed all the variable names and the parameter to product I guess for the reason I thought I might be getting using wrong values in places as some where product_id and some were producID. So now I have this.
This is where you insert product[0].item_id and product[0].item_type. This record will take only one value of item_id and item_type, the very first one under index 0, which the product query will return, even if there are several records. Is this happening? Is there data there?
Also, judging by the final task that you want to achieve, it is more appropriate to use the method proposed by Teodor with a hidden input. But in order not to confuse you even more, let’s first figure out the method using the session variable, and then we’ll figure out the way in which you can send the productID in the form using a hidden input.
So the standard item is item 1 so thats the value used in the url parameter. Subsequently the value being stored in the GET variable. So the row i want returning in this instance is row 1. But let’s say the item_id passed in the URL parameter is ?product=9 then it would be item_id 9 in the table that is filtered in the query.
This is right isn’t it?
So maybe I’m not understanding this [0] index in the binding??