Jump to content

PHP Code based on a date


mikebosh

Recommended Posts

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

Link to comment
Share on other sites

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.';
}

Link to comment
Share on other sites

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)";
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.