From ab294df97b7604eb485b70179d6134f6e3b47b85 Mon Sep 17 00:00:00 2001 From: james Date: Wed, 1 Feb 2006 16:59:45 +0000 Subject: [PATCH] Make safety questions require a question to be filled in (or at least something in the question box) --- config/safetyquestions.php | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/config/safetyquestions.php b/config/safetyquestions.php index cdfbbdf9..b4bf79de 100644 --- a/config/safetyquestions.php +++ b/config/safetyquestions.php @@ -29,7 +29,9 @@ if($_POST['action']=="save" && $_POST['save']) { - mysql_query("UPDATE safetyquestions SET + if($_POST['question']) + { + mysql_query("UPDATE safetyquestions SET question='".mysql_escape_string(stripslashes($_POST['question']))."', `type`='".mysql_escape_string(stripslashes($_POST['type']))."', `required`='".mysql_escape_string(stripslashes($_POST['required']))."', @@ -37,23 +39,29 @@ WHERE id='".$_POST['save']."' AND year='".$config['FAIRYEAR']."'"); echo mysql_error(); - echo happy(i18n("Safety question successfully saved")); - + echo happy(i18n("Safety question successfully saved")); + } + else + echo error(i18n("Question is required")); } + if($_POST['action']=="new") { - mysql_query("INSERT INTO safetyquestions (question,type,required,ord,year) VALUES ( - '".mysql_escape_string(stripslashes($_POST['question']))."', - '".mysql_escape_string(stripslashes($_POST['type']))."', - '".mysql_escape_string(stripslashes($_POST['required']))."', - '".mysql_escape_string(stripslashes($_POST['ord']))."', - '".$config['FAIRYEAR']."' - )"); - echo mysql_error(); - - echo happy(i18n("Safety question successfully added")); - + if($_POST['question']) + { + mysql_query("INSERT INTO safetyquestions (question,type,required,ord,year) VALUES ( + '".mysql_escape_string(stripslashes($_POST['question']))."', + '".mysql_escape_string(stripslashes($_POST['type']))."', + '".mysql_escape_string(stripslashes($_POST['required']))."', + '".mysql_escape_string(stripslashes($_POST['ord']))."', + '".$config['FAIRYEAR']."' + )"); + echo mysql_error(); + echo happy(i18n("Safety question successfully added")); + } + else + echo error(i18n("Question is required")); } if($_GET['action']=="remove" && $_GET['remove'])