-
Notifications
You must be signed in to change notification settings - Fork 0
/
upload.php
59 lines (46 loc) · 1.94 KB
/
upload.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
<?php
session_start();
require_once ('db.php');
global $email_exist, $success_msg ;
if($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['email_check']) && $_POST['email_check'] == 1) {
$mail = $_POST['mail'];
$stmt = $conn->prepare("SELECT count(*) as cntMail FROM employee WHERE mail=:mail");
$stmt->bindValue(':mail', $mail, PDO::PARAM_STR);
$stmt->execute();
$count = $stmt->fetchColumn();
if($count > 0){
echo "Sorry! email has already taken. Please try another.";
}
exit;
}
if (isset($_POST['Submit'])) {
move_uploaded_file($_FILES["image"]["tmp_name"],"uploads/" . $_FILES["image"]["name"]);
$location = $_FILES["image"]["name"];
$fname = $_POST['fname'];
$mname = $_POST['mname'];
$lname = $_POST['lname'];
$gender = $_POST['gender'];
$mail = $_POST['mail'];
$mobile_no = $_POST['mobile_no'];
$date_of_birth = $_POST['date_of_birth'];
$e_status = $_POST['e_status'];
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "INSERT INTO employee (fname, mname, lname, gender, mail, mobile_no, date_of_birth, e_status, photograph)
VALUES ('$fname', '$mname', '$lname', '$gender', '$mail', '$mobile_no', '$date_of_birth', '$e_status', '$location')";
$conn->exec($sql);
$states = $_POST['states'];
$country = $_POST['country'];
$id = $conn->lastInsertId();
foreach($_POST['add_line1'] as $k => $val) {
$q2 = "INSERT INTO eaddress (employee_id, add_line1, states, country) VALUES ('$id', '$val', '$states', '$country')";
$conn->exec($q2);
}
if(!$q2){
} else {
$_SESSION['message'] = 'Successfully Added !!!';
header('location:index.php');
//echo "<script>alert('Successfully Added!!!'); window.location='index.php'</script>";
exit;
}
}
?>