-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinsert.php
More file actions
84 lines (73 loc) · 3.63 KB
/
insert.php
File metadata and controls
84 lines (73 loc) · 3.63 KB
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
<?php
session_start();
// ເຊື່ອມຕໍ່ກັບຖານຂໍ້ມູນ
require('connectdb.php');
// ຮັບຄ່າຈາກຟຣອມບັນທຶກຂໍ້ມູນ Check ຄ່າແຕ່ລະຕົວແປ່ຣ
if(isset($_POST["insert"])){
$Firstname = $_POST["Firstname"];
$Lastname = $_POST["Lastname"];
$Birthday = $_POST["Birthday"];
$Gender = $_POST["Gender"];
$Age = $_POST["Age"];
$Career = $_POST["Career"];
$Village = $_POST["Village"];
$District = $_POST["District"];
$Province = $_POST["Province"];
$Phone = $_POST["Phone"];
$Email = $_POST["Email"];
$Password = $_POST["Password"];
$Subject = $_POST["Subject"];
// ກວດສອບວ່າມີຂໍ້ມູນຫຼືບໍ່
if(empty($_POST["Firstname"])){
$_SESSION["error"] = 'ກະລຸນາປ້ອນຊື່ຂອງທ່ານ';
header("Location: form.php");
}else if(empty($_POST["Lastname"])){
$_SESSION["error"]= 'ກະລຸນາປ້ອນນາມສະກຸນຂອງທ່ານ';
header("Location: form.php");
}else if(empty($_POST["Birthday"])){
$_SESSION["error"]= 'ກະລຸນາເລືອກວັນເດືອນປີເກີດຂອງທ່ານ';
header("Location: form.php");
}else if(empty($_POST["Gender"])){
$_SESSION["error"]= 'ກະລຸນາເລືອກເພດ';
header("Location: form.php");
}else if(empty($_POST["Age"])){
$_SESSION["error"]= 'ກະລຸນາປ້ອນອາຍຸຂອງທ່ານ';
header("Location: form.php");
}else if(empty($_POST["Career"])){
$_SESSION["error"]= 'ກະລຸນາປ້ອນອາຊີບ';
header("Location: form.php");
}else if(empty($_POST["Village"])){
$_SESSION["error"]= 'ກະລຸນາປ້ອນຊື່ບ້ານ';
header("Location: form.php");
}else if(empty($_POST["District"])){
$_SESSION["error"]= 'ກະລຸນາປ້ອນຊື່ເມືຶອງ';
header("Location: form.php");
}else if(empty($_POST["Province"])){
$_SESION["error"]='ກະລຸນາປ້ອນຊື່ແຂວງ';
header("location: from.php");
}else if(empty($_POST["Phone"])){
$_SESSION["warning"]= 'ກະລຸນາປ້ອນເບີໂທລະສັບ';
header("Location: form.php");
}else if(empty($_POST["Email"])){
$_SESION["warning"]='ກະລຸນາປ້ອນອີເມລຂອງທ່ານ';
header("location: from.php");
}else if(empty($_POST["Password"])){
$_SESSION["warning"]='ກະລຸນາປ້ອນລະຫັດຜ່ານຂອງທ່ານ';
header(" location: from.php");
}else if(empty($_POST["Subject"])){
$_SESSION["error"]= 'ກະລຸນາເລືອກສາຂາຮຽນ';
header("Location: form.php");
}else{
// ການບັນທຶກ
$sql= "INSERT INTO students(Firstname,Lastname,Birthday,Gender,Age,Career,Village,District,Province,Phone,Email,Password,Subject)
VALUE('$Firstname','$Lastname','$Birthday','$Gender','$Age','$Career','$Village','$District','$Province','$Phone','$Email','$Password','$Subject')";
// echo $sql;
$result = mysqli_query($Connect,$sql);//ສັງລັນຄຳສັ່ງ SQL
if($result){
header("location:showdata.php");
}else{
echo mysqli_error($Connect);
}
}
}
?>