-
Notifications
You must be signed in to change notification settings - Fork 1
/
add_trainer.php
67 lines (48 loc) · 1.89 KB
/
add_trainer.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
require('db.php');
$errors = array();
if (isset($_REQUEST['trainer'])) {
$trainer_id = mysqli_real_escape_string($conn, $_REQUEST['id']);
$name = mysqli_real_escape_string($conn, $_REQUEST['name']);
$time = mysqli_real_escape_string($conn, $_REQUEST['time']);
$mobileno = mysqli_real_escape_string($conn, $_REQUEST['mobileno']);
$pay_id = mysqli_real_escape_string($conn, $_REQUEST['pay_id']);
$user_check_query = "SELECT * FROM trainer WHERE trainer_id='$trainer_id' LIMIT 1";
$result = mysqli_query($conn, $user_check_query);
$user = mysqli_fetch_assoc($result);
if ($user) {
if ($user['trainer_id'] === $trainer_id) {
array_push($errors, "<div class='alert alert-warning'><b>ID already exists</b></div>");
}
}
if (count($errors) == 0) {
$query = "INSERT INTO trainer (trainer_id,name,time,mobileno,pay_id)
VALUES('$trainer_id','$name','$time','$mobileno','$pay_id')";
$sql=mysqli_query($conn, $query);
if ($sql) {
$msg="<div class='alert alert-success'><b>Trainer added successfully</b></div>";
}else{
$msg="<div class='alert alert-warning'><b>Trainer not added</b></div>";
}
}
}
?>
<div class="container">
<form class="mt-3 form-group" method="post" action="">
<h3>ADD TRAINER</h3>
<?php include('errors.php');
echo @$msg;
?>
<label class="mt-3">TRAINER ID</label>
<input type="text" name="id" class="form-control">
<label class="mt-3">TRAINER NAME</label>
<input type="text" name="name" class="form-control">
<label class="mt-3">TIME</label>
<input type="text" name="time" class="form-control">
<label class="mt-3">MOBILE NO</label>
<input type="text" name="mobileno" class="form-control">
<label class="mt-3">PAYMENT AREA ID</label>
<input type="text" name="pay_id" class="form-control">
<button class="btn btn-dark mt-3" type="submit" name="trainer">ADD</button>
</form>
</div>