Hi
I'm using Chronoforms to email me competition entries but I require it to update another 2 tables in the database and subtract a credit from a users account when the form is submitted.
I've put this code in the onSubmit form code box:
The thing is it doesn't update either of the tables that it should. Am I missing something that will make the queries happen, maybe a setting somewhere else in Chronoforms, or have I just got the code wrong?
Thanks
I'm using Chronoforms to email me competition entries but I require it to update another 2 tables in the database and subtract a credit from a users account when the form is submitted.
I've put this code in the onSubmit form code box:
<?php
echo ("Thank You For Your Submission");
$database =& JFactory::getDBO();
$user =& JFactory::getUser();
$database->setQuery( "UPDATE jos_vodes_credits SET credit=credit-1 WHERE userid='{$user->id}'" );
$database->query();
$qry="UPDATE `jos_vodes_campaign_balance` SET credits_used=credits_used+1,balance=balance-1 WHERE userid='{$user->id}' and campaign_id in(select id from `jos_vodes_campaigns` WHERE published=1);";
$database->setQuery($qry);
$database->query();
?>
The thing is it doesn't update either of the tables that it should. Am I missing something that will make the queries happen, maybe a setting somewhere else in Chronoforms, or have I just got the code wrong?
Thanks