1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
| if (isset($_POST['cancel'])){
if (! empty($_POST)) {
$_POST=array();
}
} // End of Cancel
else if (isset($_POST['submitted'])) { // Handle the form.
require_once ('../mysqli_connect.php');
include ('includes/login_functions.inc.php');
//empty $errors
$errors=array();
// Trim all the incoming data:
$trimmed = array_map('trim', $_POST);
if (empty($_POST['brulecode'])){
$errors[]= 'Please enter a Business code. It is a mandatory field';
} else {
$brc=$_POST['brulecode']);
}
if (empty($_POST['bruletype'])){
$errors[]= 'Please enter a Business type. It is a mandatory field';
} else {
$brt=$_POST['bruletype']);
}
if (empty($_POST['brulecontent'])){
$errors[]= 'Please enter a Field in Rule Content. It is a mandatory field';
} else {
$frc=$_POST['brulecontent']);
}
if (empty($errors)) {
$q = "INSERT INTO business_rules ('Biz_rule_ID', Biz_rule_code, Rule_type, Rule_content, BR_description) VALUES ('', '$brc', '$brt', '$frc', '$brd')";
$r = mysqli_query ($dbc, $q) or trigger_error("Query: $q\n<br />MySQL Error: " . mysqli_error($dbc));
if (mysqli_affected_rows($dbc) == 1) { // If it ran OK.
echo '<p> The business rule has been added in the system. </p>';
// Clear $_POST (so that the form's not sticky):
$_POST=array();
mysqli_close($dbc);
} else { //Not OK
echo '<p class="error">You could not be registered due to a system error. We apologize for any inconvenience.</p>';
}
} else {
echo '<h1>Error!</h1>
<p class="error">The following error(s) occurred:<br />';
foreach ($errors as $msg) {
echo " - $msg<br />\n";
}
echo '</p><p>Please try again.</p>';
}
} // End of form submitted
?>
<h1> > Create a Business Rule </h1>
<form action="create_br.php" method="post">
<fieldset style="width: 500px" >
<legend>CBR</legend>
<table align="left" border = "0" cellspacing ="0" cellpadding="3">
<tr><td><b>Business Rule Code:</b></td> <td><input type="text" name="brulecode" style="background:#FFFFCC" size="20" maxlength="20" value="<?php if (isset($trimmed['brulecode'])) echo $trimmed['brulecode']; ?>" /></td></tr>
<tr><td><b>Business Rule Type:</b></td> <td> <input type="text" name="bruletype" style="background:#FFFFCC" size="20" maxlength="40" value="<?php if (isset($trimmed['bruletype'])) echo $trimmed['bruletype']; ?>" /></td></tr>
<tr><td><b>Field in Rule Content:</b></td> <td> <input type="text" name="brulecontent" style="background:#FFFFCC" size="20" maxlength="40" value="<?php if (isset($trimmed['brulecontent'])) echo $trimmed['brulecontent']; ?>" /></td></tr>
<tr><td><b>Description:</b></td> <td> <textarea name="bruledescription" rows="5" cols="30" wrap="hard" ><?php if (isset($_POST['bruledescription'])) echo $_POST['bruledescription']; ?></textarea> </td></tr>
<tr>
<td></td>
<td><div align="center"><input type="submit" name="submit" value="Register" /></div></td>
<td><div align="center"><input type="submit" name="cancel" value="Cancel" /></div></td>
</tr>
<input type="hidden" name="submitted" value="TRUE" />
</table>
</fieldset>
</form> |