I want to do something really simple, but have to use Joomla what makes it probably complicated because I have less experience in Joomla development.

I have field with a value (a number) which is declared by another component and saved in the joomla database. Then I have a submite button in a form (I'm using chronoforms5 by the way).

What I want is to change the value of my field after pressing the submit button of my form.

Usually I would write a PHP file with the database connection, query etc. and wrting a javascript handler for the button which makes an AJAX call to that PHP file. But how can I do that by using Joomla? I'm searching for a simple solution, security is almost not relevant. Thanks!


Since you are using a form extension you need to do it following its options and features. I haven't that big experience with Chronoforms but I would look for an on-submit option to run custom code. I am not sure if you need to implement AJAX (js on submit to some server side action) or simply just a php snippet that will update whatever you want to update on the database.

It's also possible that chronoforms may provide another internal way to allow manipulation of database data from the form - so exhaust first every possibility within chronoforms by studying its documentation.

Finally, it's not clear in your question if you are asking how to do CRUD database things... If that's what you are asking check here:


  • Thanks for your reply. It seems like it is possible to use a php snippet in chronoforms. And yes, I really want to read a table from the database and manipulate (Update) entries. This is what you call 'CRUD database things', isn't it? – Patrick Münster Jun 30 '17 at 11:36
  • @PatrickMünster: Create, Read, Update, Delete – FFrewin Jun 30 '17 at 11:53

I've read some of the Chronoforms 5 documentation. After that I was able to write some custom code in the "Custom Code" element added at the end of a normal Chronoforms form with submit button. The following code will be executed after a successful submit. It reads a "POST" parameter, loads a field from the database and update it after making some changes. Suggestions and improvements are still desired.

    // Get a db connection.
    $db = JFactory::getDbo();

    // Create a new query object.
    $query = $db->getQuery(true);

    // Get event ID from form post
    $eventID = $form->data['eventID'];
    $numberOfTickets = $form->data['numberOfTickets'];

    //#### GET FIELD FROM DB ####//

    // Conditions for which records should be updated and selected.
    $conditions = array(
        $db->quoteName('search') .'='. $db->quote('event-id'.$eventID)


    $availableTickets = $db->loadResult();

    //#### UPDATE FIELD FROM DB ####//

    // Fields to update .
    $availableTickets = (int)$availableTickets - (int)$numberOfTickets;
    if ($availableTickets < 0) {
        $availableTickets = 0;

    $fields = array(
        $db->quoteName('replace') . ' = '. $db->quote($availableTickets)


    $result = $db->execute();


Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.