-
Notifications
You must be signed in to change notification settings - Fork 0
/
newcurriculm.php
42 lines (34 loc) · 993 Bytes
/
newcurriculm.php
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
<?php
include 'db.php';
if($_SERVER['REQUEST_METHOD'] == 'POST'){
$errors = array();
if(preg_match("/\S+/", $_POST['cur']) === 0){
$errors['cur'] = "* Curriculum is required.";
}
if(preg_match("/\S+/", $_POST['des']) === 0){
$errors['des'] = "* Description is required.";
}
if(count($errors) === 0){
$cur=$_POST['cur'];
$des=$_POST['des'];
$user = $_SESSION['ID'];
if(empty($_POST['id'])){
$sql=mysqli_query($conn, "INSERT into program (PROGRAM, DESCRIPTION) VALUES ( '$cur', '$des' )");
}else{
$sql=mysqli_query($conn, "UPDATE program set PROGRAM='$cur', `DESCRIPTION`='$des' where PROGRAM_ID = ".$_POST['id']);
}
if ($sql){
echo "<script>
alert('New program successfully saved');
window.location.href='rms.php?page=program';
</script>";
} else {
echo "<script>
alert('New program failed to record!" .$sql."');
window.location.href='rms.php?page=program';
</script>";
}
}
}
mysqli_close($conn);
?>