forked from BE-PROJECTS2018/GroupNo45-Pantomath-bo
-
Notifications
You must be signed in to change notification settings - Fork 1
/
register.php
88 lines (73 loc) · 2.44 KB
/
register.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
include './serverScript/class/Database.php';
if(isset($_POST["submit"])){
$Fname = $_POST["fname"];
$Lname = $_POST["lname"];
$age = $_POST["age"];
$image_data = $_POST["image_data"];
$college = $_POST["college"];
$stream = $_POST["stream"];
$email = $_POST["email"];
$phone = $_POST["phone"];
$degree = $_POST["degree"];
$experience = $_POST["experience"];
$name = $Fname . " " . $Lname;
/**
* Receive file and store to candidate directory
*/
$uploadDir = "candidate/Resume/";
$uploadfile = $email . "_" . basename($_FILES["file"]["name"]);
/*
if(move_uploaded_file($_FILES['resume']['tmp_name'], $uploadfile))
{
echo "The file has been uploaded successfully";
}
else
{
echo "There was an error uploading the file";
}
*/
$temp_name = $_FILES['file']['tmp_name'];
if(isset($name)){
if(!empty($name)){
$location = $uploadDir;
if(move_uploaded_file($temp_name, $location.$uploadfile)){
echo 'File uploaded successfully';
}
}
} else {
echo 'You should select a file to upload !!';
}
/**
* convert image data uri to image file
*/
$file_path = "candidate/Images/" . $email . "__Image.jpeg";
$img = str_replace('data:image/jpeg;base64,', '', $image_data);
$img = str_replace(' ', '+', $img);
$img = base64_decode($img);
file_put_contents($file_path, $img);
$db = new Database();
$db->connect();
$db->insert('pb_candidate_details',array(
'name'=>$name,
'age'=>$age,
'college'=>$college,
'resume'=>$location.$uploadfile,
'photo'=>$file_path,
'degree'=>$degree,
'experience'=>$experience,
'mobile'=>$phone,
'email'=>$email,
'Stream'=>$stream));
$res = $db->getResult();
$db->disconnect();
$error="false";
if(strlen($res[0][0] . "")>2){
//echo 'Some Error Occured';
$error="true";
}
echo '<script type="text/javascript">
window.location = "./index.php?error=' . $error . '";
</script>';
}
?>