mikebosh Posted April 2, 2018 Share Posted April 2, 2018 Hi Have this PHP code on a form which restricts the number of submissions allowed want to chnge it to stop excepting submissions after a set date not sure how to change / Define the maximum number of submissions. For this example we'll use 50.$max = 50;// Get a database connection.$db = JFactory::getDbo();// Setup the query. This query counts the number of submissions for the current form.// $formId contains the ID of the current form.$db->setQuery("SELECT COUNT(`SubmissionId`) FROM #__rsform_submissions WHERE `FormId`='".(int) $formId."'");$submissions = $db->loadResult();if ($submissions >= $max) { $formLayout = 'Sorry, no more submissions are accepted.';} Thanks in advance Mike Quote Link to comment Share on other sites More sharing options...
Barand Posted April 2, 2018 Share Posted April 2, 2018 $closing_date = '2018-04-01'; if ($submissions >= $max || date('Y-m-d') > $closing_date) { $formLayout = 'Sorry, no more submissions are accepted.'; } Quote Link to comment Share on other sites More sharing options...
mikebosh Posted April 2, 2018 Author Share Posted April 2, 2018 Hi Great thanks Mike Quote Link to comment Share on other sites More sharing options...
mikebosh Posted April 2, 2018 Author Share Posted April 2, 2018 Hi Sorry should have tested fully have this code and I get message 'Sorry, no more submissions are accepted' when it should display $closing_date = '2018-04-10';if ($submissions >= $max || date('Y-m-d') > $closing_date) { $formLayout = 'Sorry, no more submissions are accepted.';} Quote Link to comment Share on other sites More sharing options...
mikebosh Posted April 2, 2018 Author Share Posted April 2, 2018 Hi Its on a joomla site using RS Forms Script called on form displaysee image Quote Link to comment Share on other sites More sharing options...
mikebosh Posted April 3, 2018 Author Share Posted April 3, 2018 Hi Barand Any idea why your surgested code did not work Thanks Mike Quote Link to comment Share on other sites More sharing options...
Barand Posted April 3, 2018 Share Posted April 3, 2018 Any idea why you expect that blindly copy/pasting a code example into your application should work? Quote Link to comment Share on other sites More sharing options...
mikebosh Posted April 3, 2018 Author Share Posted April 3, 2018 Dont bother Quote Link to comment Share on other sites More sharing options...
requinix Posted April 3, 2018 Share Posted April 3, 2018 According to the first sample of code you posted, Barand's thing will work. But this new UI you showed the screenshot of? How do you know that $submissions and $max are things that even exist? What if you do $formLayout .= " (submissions=$submissions, max=$max)"; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.