Last active
October 8, 2021 03:12
-
-
Save thuan1412/4abd9de48f0530b1f56e47f4438ecce1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require 'congty.php'; | |
// Nếu người dùng submit form | |
if (!empty($_POST['add_student'])) | |
{ | |
// Lay data | |
$data['macty'] = isset($_POST['txtmact']) ? (string)$_POST['txtmact'] : ''; | |
$data['ten'] = isset($_POST['txthoten']) ? (string)$_POST['txthoten'] : ''; | |
$data['diachi'] = isset($_POST['txtdiachi']) ? (string)$_POST['txtdiachi'] : ''; | |
$data['dthoai'] = isset($_POST['txtdienthoai']) ? $_POST['txtdienthoai'] : ''; | |
$data['email'] = isset($_POST['txtemail']) ? (string)$_POST['txtemail'] : ''; | |
$data['namtlap'] = isset($_POST['txtnam']) ? (string)$_POST['txtnam'] : ''; | |
$data['giamdoc'] = isset($_POST['giamdoc']) ? (string)$_POST['giamdoc'] : ''; | |
$data['linhvuc'] = isset($_POST['txtlinhvuc']) ? (string)$_POST['txtlinhvuc'] : ''; | |
// Validate thong tin | |
$errors = array(); | |
if (empty($data['macty'])){ | |
$errors['macty'] = 'Chưa nhập ma congty'; | |
} | |
if (empty($data['ten'])){ | |
$errors['ten'] = 'Chưa nhập ten cong ty'; | |
} | |
if (empty($data['diachi'])){ | |
$errors['diachi'] = 'Chưa nhập dia ci'; | |
} | |
if (empty($data['email'])){ | |
$errors['email'] = 'Chưa nhập email'; | |
} | |
if (empty($data['namtlap'])){ | |
$errors['namtlap'] = 'Chưa nhập nam thanh lap'; | |
} | |
if (empty($data['giamdoc'])){ | |
$errors['giamdoc'] = 'Chưa nhập ten giam doc'; | |
} | |
if (empty($data['linhvuc'])){ | |
$errors['linhvuc'] = 'Chưa nhập linh vuc'; | |
} | |
// Neu ko co loi thi insert | |
if (!$errors){ | |
add_student($data['macty'], $data['ten'], $data['diachi'], $data['dthoai'], $data['txtemail'], $data['txtnam'], $data['giamdoc'], $data['linhvuc']); | |
// Trở về trang danh sách | |
header("location: index.php"); | |
} | |
} | |
disconnect_db(); | |
?> | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Thông tin công ty</title> | |
</head> | |
<body> | |
<form name="" action="/congty/them-congty.php" method="POST"> | |
<center> | |
<h2>NHẬP THÔNG TIN CÔNG TY</h2> | |
<table border="1" cellpadding="1" cellspacing="2" width="40%" height="450px"> | |
<tr> | |
<td>Mã công ty</td> | |
<td><input type="text" name="txtmact" size="20" placeholder="Nhập mã công ty"><font color="red"><i>(*)</i></font></td> | |
</tr> | |
<tr> | |
<td>Tên công ty</td> | |
<td><input type="text" name="txthoten" size="30" placeholder="Nhập tên công ty"></td> | |
</tr> | |
<tr> | |
<td>Địa chỉ</td> | |
<td><textarea name="txtdiachi" cols="40" rows="2" placeholder="Nhập địa chỉ"></textarea></td> | |
</tr> | |
<tr> | |
<td>Điện thoại</td> | |
<td><input type="" name="txtdienthoai" size="15" placeholder="Nhập số điện thoại"></td> | |
</tr> | |
<tr> | |
<td>Email</td> | |
<td><input type="text" name="txtemail" size="15" placeholder="Nhập email"></td> | |
</tr> | |
<tr> | |
<td>Năm thành lập</td> | |
<td><input type="text" name="txtnam" size="20" placeholder="Nhập năm thành lập"> <font color="red"><i>(dd/mm/yyyy)</i></font></td> | |
</tr> | |
<tr> | |
<td>Giám đốc</td> | |
<td><input type="text" name="txtgiamdoc" size="15" placeholder="Nhập tên giám đốc"></td> | |
</tr> | |
<tr> | |
<td>Lĩnh vực</td> | |
<td><input type="text" name="txtlinhvuc" size="30" placeholder="Nhập lĩnh vực"></td> | |
</tr> | |
<tr align="center"> | |
<td colspan="2"><input type="Submit" name="" value="Lưu"> <input type="Reset" name="" value="Nhập lại"></td> | |
</tr> | |
</table> | |
</center> | |
</form> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment