Using Mautic for a petition. How can I

I’m using Mautic for an online petition and have it all set up and working great.

I’m looking for a method to show how many records have been submitted and the target number we’re looking to capture on the landing page displaying something like a horizontal thermometer.

Does anyone have advice on how to go about adding that functionality to Mautic?

With super simple coding you can do it.
Just count the submissions in the right form and push it out on your website. You can embed that number.

Hey Joey,

I’m totally green coding on Mautic, but I was able to achieve the query outside of Mautic, but when I place the code into the landing page, PHP is getting disabled by the builder.

<!--?php
$sql = "SELECT * FROM `form_submissions` WHERE `form_id`=5;";
if ($result=mysqli_query($conn,$sql)) {
$rowcount=mysqli_num_rows($result);
echo "The total number of rows are: ".$rowcount; 
}
?-->

Any ideas on circumventing that?

I do not think builder allows putting php code into builder.

What I would probably do in your situation is:

  • create custom php script and place it on your server so its accessbile from the web (as far as I can tell you already started :))
  • on your landingpage where you have thermometer I would create a simple JS script that makes request to this php script you created earlier
  • the php should return number of records in the form and you can now use that info to display thermometer correctly.

Thanks for the suggestion, that points me in the right direction. It’s a bit over my pay grade, but I’ll look into it deeper. I do have the PHP script done and found that Mautic prevents calling PHP directly through the .htaccess file.

No problem. Let me know if you get stuck and need additional help.

You can place it in your mautic.ltd/petition/ folder and name it index.php
You can call index.php files :slight_smile: