Add new record in my database

CDLMQSE 14 Nov, 2025

Hello,

I've designed a form for updating a database table. It works. The problem is that I can't add a new record through this form. I tried creating a link to the form with the parameter `chronopage=edit` to call it and without an `id` parameter, but the form isn't blank ; it's already populated with the data from the previous open record. Would it be better to create a separate form for adding records ?

Thank you for your insights.

Max_admin 14 Nov, 2025

Hi

You need a PHP action at the start of the page to check if the "id" parameter exists or not, if it exists then Read Data, if not then do nothing

You can use the PHP Events behavior for that.

Let me know if you need a screenshot

Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
CDLMQSE 15 Nov, 2025

Hi Max,

Thanks for your response. I begin like this but, yes, I need a sreenshot of what it should be made

Max_admin 15 Nov, 2025
Answer

Here is how it should look like:

Add new record in my database image 1

and here is the code:

if(!empty($this->data("id"))){
    return "read";
}else{
    return "blank";
}

You check $this->data because id will be passed as a query parameter in the form URL

Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
CDLMQSE 16 Nov, 2025

Unfortunately it still doesn't work, my form is still not blank, it is still completed with data from the previous record consulted.I attach a capture (two pictures) for a better evaluation of the pb.

Max_admin 18 Nov, 2025

Hi

Try to add the Clear Session action at the start of the editing page:

Add new record in my database image 2

Does this help ?

According to your image the reading will only happen when the "id" parameter is passed, but once you read it and the data is merged, the data will not be reset until the editing page is submitted, and if you do not do that then the data will stay there.

Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
CDLMQSE 18 Nov, 2025

Hi Max,

Unfortunately, it's still not working. The creation form displays the last viewed record. Can I send you a backup of the form for analysis ? How ?

Thanks a lot.

Max_admin 18 Nov, 2025

Hi CDLMQSE

Instead of the Clear Session action, please try a PHP action with this code:

$this->data=[];

Add this action in the "blank" event of the PHP which checks for "id", you can also add that line in the main PHP itself inside the "blank" branch

What do you get ?

Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
CDLMQSE 20 Nov, 2025

Unfortunately, I haven't gotten any better results, but I think I've found the source of the problem and the solution.

In my initial request, I specified that I'm calling a form for a new record, omitting the `id` variable from the URL. However, the condition tests for the variable to be empty or null. Since it's absent from the URL, the condition is never met. So, I've added a null `id` variable to the URL. And it works !

Max_admin 20 Nov, 2025

This will work because you pass an empty value to the WHERE statement in Read Data, but you better do it the way I suggested:

Add new record in my database image 3

That way the Read Data does not run and the data from previous read is reset.

Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
CDLMQSE 21 Nov, 2025

Unfortunately, this doesn't work.

Max_admin 21 Nov, 2025

The form is not empty when there is no id parameter in the browser's address bar ?

Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Max_admin 22 Nov, 2025

Does the debug show that the main PHP check is returning "blank" ?

Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
CDLMQSE 23 Nov, 2025

Here's what I have in debug mode.

Max_admin 25 Nov, 2025

For the latest debug your posted please post the URL in the address bar and screenshots of the Load event of that page

You may also attach the whole form if you like and mark it as "Private"

Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Post a Reply