How can I run a MySQL query from the onclick event of an HTML button on my site?

For example if my button is created like so, how could I use this to run a MySQL query titled AddInfo

<p><button type="button">Run A SQL Stored Procedure</button></p>

1 Answer 1


You need PHP for that. Here's an example :

<form action='' method='POST'>
<input type='submit' name='submit' />

and then

//execute mysql query

Use Sourcerer to include PHP scripts inside a custom HTML module.


How to use Sourcerer ?

  • After the plugin is installed, a button (CODE) is added below the WYSIWYG editor :

enter image description here

  • Clicking on Code button opens a pop-up, enter your code between {source} and {/source} tags like this:

enter image description here

  • Hit the green Insert button to add this code to your Article or Custom HTML module :)
  • 1
    You don't need to include html tags ;) they already exist in the template
    – Lodder
    Apr 16, 2016 at 19:55
  • I have installed this extension, how to use it in my article so that I can use the syntax? Does Joomla auto-detect that the extension is installed and can use PHP? Apr 17, 2016 at 2:33
  • 1
    @NadineSmithJonesPicard Answer updated with Sourcerer tutorial ;)
    – saibbyweb
    Apr 17, 2016 at 5:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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