Using sessions issue

Everything is right.

So the product query will always return one record, right? If this is the case, then you can use Single Query for product. However, your record product[0].item_id should also work when using a normal query.

So, you get some data from the product query, here?

Yes so I go to Insert Options in the Data Insert Action and add the bindings from the query… See video

It is necessary to check whether the value of $_GET.product is coming to the server. To do this, you can disable both the query step and the insert step. Create a Set Value step (enable its output) and assign it the value $_GET.product. And then open the debugger in Chrome, go to the network tab (Fetch/XHR), and see what the server action returns when you go to page 2.

It is important to understand whether Set Value returns the correct product value.

OK Thanks @Mr.Rubi i’ll try this!

So with the Data query and Data insert ENABLED as normal … Page 2 gets this 500 error

With the t actions DISABLED and a SET VALUE using GET value ENABLED it looks like the value is returned correctly.

I’ve thought about your task again. What you want to do should be done with a hidden input. It is incorrect to use the session variable here.

:see_no_evil:

The problem is that you combine two completely different actions by nature. The first action is to get the data and then display it on the page. It is done by Server Connect on the client side and getting data from database queries. But there should be no insertion steps in such server actions.

If you need to insert data into the database, you need to send this data using the form using the POST method. In the form, you can use any parameters from the page. After that, you will send them to the server and do all the necessary actions, including inserting them into the database.

Initially, I thought that you wanted to send a form to write to the database, and then, when going to page 2, display data from the product table using a filter based on the session variable. However, you only need to make a record. In this case, you do not need to use Server Connect on the page. It is required to use the form and in which you send $_POST.name , $_POST.username, $_POST.password. In the same form, create a hidden product input (on the server side, the value will be in $_POST.product), as Teodor recommended above:

<input type="hidden" name="product" id="product" value="" dmx-bind:value="query.product">

Steven, I may have confused you. I’m sorry, initially I misunderstood your task. Your task is very easy to solve in the Wappler. For a better understanding, I have made a short guide:

  1. On the client side, we set the query variable:
  2. Create a form with the necessary inputs. In my case, these are three inputs (inp_f1, inp_f1 and product). The product input is hidden and takes a value equal to the value of the query parameter:
  3. Connect the server action to the form, which will be responsible for insert:
  4. Create a dynamic event for the form that is triggered when the server action that the form uses is done:
  5. In the event, we indicate the transition to another page:
  6. On the server side, in the server action, we create a Single Query step in which we use the value $_POST.product as a filter, which we get from the form:
  7. The second step is insert. In one of the fields we insert the data obtained from the first query:
  8. On the client side, on the second page, we make a table reflecting the result of the insert:

You are a legend! @Mr.Rubi many thanks. I’ll have a look at this and try it out. Any problems i’ll be sure to give you a heads up! :grin: :+1:

1 Like