-
Notifications
You must be signed in to change notification settings - Fork 0
/
addlecturer.php
67 lines (66 loc) · 2.2 KB
/
addlecturer.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
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
<?php
session_start();
require_once "includer.php";
if(!is_admin()){
redirect("adminlogin.php");
}
$name = post("name");
$phone = post("phone");
$idnumber = post("idnumber");
$email = post("email");
function process(){
if(!no_post("save")){
$name = post("name");
$phone = post("phone");
$idnumber = post("idnumber");
$email = post("email");
if(empty($name) || empty($phone) || empty($idnumber) || empty($email)){
return "All the fields are required";
}
$saved = Lecturer::save($name, $phone, $idnumber, $email);
if(!$saved){
return "There was problem saving the record. Try again later";
}
return "Y";
}
return null;
}
$error = process();
$success = null;
if($error === "Y"){
$success = "The lecturer was successfully saved.";
$error = null;
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Add course</title>
<?php include_once "includes/styles.php"; ?>
<style>
.center{
margin-top: 12vh;
}
</style>
</head>
<body>
<?php include_once "includes/admin_nav_logged_in.php";?>
<div class="col-md-4 offset-4 center p-4">
<h3 class="text-center">Add Lecturer</h3>
<br>
<?php if($error) {?>
<p class="bg-danger text-white p-2"><?= $error ?></p>
<?php } else if($success) {?>
<p class="bg-success text-white p-2"><?= $success ?></p>
<?php } ?>
<form method="post">
<input type="text" name="name" class="form-control" placeholder="Legal names" value="<?= $name ?>" required><br>
<input type="number" name="idnumber" class="form-control" placeholder="ID or Passport" value="<?= $idnumber ?>" min="10000000" max="40000000" required><br>
<input type="tel" name="phone" class="form-control" placeholder="Phone number" value="<?= $phone ?>" required><br>
<input type="email" name="email" class="form-control" placeholder="Email address" value="<?= $email ?>" required><br>
<button class="btn btn-primary btn-block btn-sm" name="save" type="submit">Save record <i class="fa fa-arrow-circle-right"></i> </button>
</form>
</div>
<?php include_once "includes/scripts.php"; ?>
</body>
</html>