-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddCompany.php
More file actions
47 lines (43 loc) · 1.11 KB
/
Copy pathaddCompany.php
File metadata and controls
47 lines (43 loc) · 1.11 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
<?php
/**
* Created by PhpStorm.
* User: Gabriel
* Date: 02/05/2018
* Time: 15:39
*/
include_once "borders.php";
if (!isset($_SESSION['id'])) {
header("Location: index.php");
exit();
}
if(isset($_POST['add'])) {
include_once 'database.php';
$name = mysqli_real_escape_string($conn, $_POST['CompanyName']);
$mail = mysqli_real_escape_string($conn, $_POST['CompanyMail']);
if(empty($name) || empty($mail)) {
header("Location: addCompany.php?error=fieldEmpty");
exit();
}
else {
$sql = "INSERT INTO company(NameCompany, MailCompany) SET ($name, $mail)";
$result1 = mysqli_query($conn, $sql);
$res = mysqli_fetch_assoc($result1);
if(!$res){
header("Location: addCompany.php?error=loginError");
exit();
}
else{
//login successful
header("Location : index.php");
}
}
}
?>
<form action="addCompany.php" method="POST">
<input type="text" name="CompanyName" placeholder="Company Name">
<input type="text" name="CompanyMail" placeholder="Company Mail">
<button type="submit" name="add">Add Company</button>
</form>
<?php
include_once "footer.php";
?>