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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.