I am writing a modification package for the forum software that my site uses. In it, I have a form where the user enters data and then clicks the save button. This fires a PHP validation check before saving the settings. However, I have a couple problems.
#1 - For some reason, the code below is not working. I simply want to set these fields equal to 0 if they are empty when Save is clicked. Any ideas why this isn't working?
#2 - I have been asked by the modification team to ensure that no HTML, Javascript, etc languages can be submitted in the fields that except text values. How can I do this?PHP Code:if (empty($_POST['countdown_hour']))
$_POST['countdown_hour'] = 0;
if (empty($_POST['countdown_minute']))
$_POST['countdown_minute'] = 0;
if (empty($_POST['countdown_second']))
$_POST['countdown_second'] = 0;
Currently, this is the entire save portion of my script. Any and all help anyone can provide is tremendously appreciated! Thanks in advance!
PHP Code:$countdown_err = '';
// Saving?
if (isset($_GET['save']))
{
if (!empty($_POST['enable_countdown']))
{
if (empty($_POST['countdown_title']))
$countdown_err .= $txt['countdown_title_error'];
if ($func['strlen']($_POST['countdown_year']) != 4)
$countdown_err .= $txt['countdown_year_error'];
if (($_POST['countdown_month'] < 1) || ($_POST['countdown_month'] > 12) || (empty($_POST['countdown_month'])))
$countdown_err .= $txt['countdown_month_error'];
if (($_POST['countdown_day'] < 1) || ($_POST['countdown_day'] > 31) || (empty($_POST['countdown_day'])))
$countdown_err .= $txt['countdown_day_error'];
if ((!empty($_POST['countdown_hour'])) && (($_POST['countdown_hour'] < 0) || ($_POST['countdown_hour'] > 23)))
$countdown_err .= $txt['countdown_hour_error'];
if ((!empty($_POST['countdown_minute'])) && (($_POST['countdown_minute'] < 0) || ($_POST['countdown_minute'] > 59)))
$countdown_err .= $txt['countdown_minute_error'];
if ((!empty($_POST['countdown_second'])) && (($_POST['countdown_second'] < 0) || ($_POST['countdown_second'] > 59)))
$countdown_err .= $txt['countdown_second_error'];
if (!ereg("^[-]?[0-9]+([\.][0-9]+)?$", $_POST['countdown_year']))
$countdown_err .= $txt['countdown_year_nan'];
if (!ereg("^[-]?[0-9]+([\.][0-9]+)?$", $_POST['countdown_month']))
$countdown_err .= $txt['countdown_month_nan'];
if (!ereg("^[-]?[0-9]+([\.][0-9]+)?$", $_POST['countdown_day']))
$countdown_err .= $txt['countdown_day_nan'];
if (!empty($_POST['countdown_hour']) && (!ereg("^[-]?[0-9]+([\.][0-9]+)?$", $_POST['countdown_hour'])))
$countdown_err .= $txt['countdown_hour_nan'];
if (!empty($_POST['countdown_minute']) && (!ereg("^[-]?[0-9]+([\.][0-9]+)?$", $_POST['countdown_minute'])))
$countdown_err .= $txt['countdown_minute_nan'];
if (!empty($_POST['countdown_second']) && (!ereg("^[-]?[0-9]+([\.][0-9]+)?$", $_POST['countdown_second'])))
$countdown_err .= $txt['countdown_second_nan'];
if (empty($_POST['countdown_reached_message']))
$countdown_err .= $txt['countdown_reached_message_error'];
if (empty($_POST['countdown_hour']))
$_POST['countdown_hour'] = 0;
if (empty($_POST['countdown_minute']))
$_POST['countdown_minute'] = 0;
if (empty($_POST['countdown_second']))
$_POST['countdown_second'] = 0;
if (!empty($countdown_err))
fatal_error($countdown_err, false);
}
saveDBSettings($config_vars);
writeLog();
redirectexit('action=featuresettings;sa=countdown');
}



Reply With Quote


Bookmarks