-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate.php
More file actions
138 lines (111 loc) · 5.53 KB
/
create.php
File metadata and controls
138 lines (111 loc) · 5.53 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<?php
session_start();
// Database credentials
$hostname = 'your_hostname';
$username = 'your_username';
$password = 'your_password';
$database = 'your_database';
// Establish database connection
$conn = new mysqli($hostname, $username, $password, $database);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Process form submission
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
// Upload the portrait image
$portraitName = $_FILES['portrait']['name'];
$portraitTmpName = $_FILES['portrait']['tmp_name'];
$portraitError = $_FILES['portrait']['error'];
if ($portraitError === UPLOAD_ERR_OK) {
$portraitDestination = 'path/to/portraits/' . $portraitName;
move_uploaded_file($portraitTmpName, $portraitDestination);
}
// Insert CV data into the database
$fullName = $_POST['full_name'];
$dob = $_POST['dob'];
$placeOfBirth = $_POST['place_of_birth'];
$location = $_POST['location'];
$email = $_POST['email'];
$phoneNumber = $_POST['phone_number'];
$lastSchool = $_POST['last_school'];
$lastSchoolYear = $_POST['last_school_year'];
$lastSchoolGraduated = $_POST['last_school_graduated'];
$achievements = $_POST['achievement'];
$achievementYears = $_POST['achievement_year'];
$summary = $_POST['summary'];
$skills = $_POST['skills'];
$query = "INSERT INTO cv_data (full_name, dob, place_of_birth, location, email, phone_number, last_school, last_school_year, last_school_graduated, summary, skills, portrait)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
$stmt = $conn->prepare($query);
$stmt->bind_param("ssssssssssss", $fullName, $dob, $placeOfBirth, $location, $email, $phoneNumber, $lastSchool, $lastSchoolYear, $lastSchoolGraduated, $summary, $skills, $portraitName);
$stmt->execute();
// Redirect to a success page or perform other actions
header("Location: create_success.php");
exit();
}
// Close the database connection
$conn->close();
?>
<!DOCTYPE html>
<html>
<head>
<title>Input your data to make your CV</title>
</head>
<body>
<h1>Input your data to make your CV</h1>
<form method="post" action="create.php" enctype="multipart/form-data">
<label for="portrait">Upload Portrait:</label>
<input type="file" id="portrait" name="portrait" accept="image/jpeg, image/png" maxlength="5242880" required>
<label for="full_name">Full Name:</label>
<input type="text" id="full_name" name="full_name" required><br><br>
<label for="dob">Date of Birth:</label>
<input type="date" id="dob" name="dob" required><br><br>
<label for="place_of_birth">Place of Birth:</label>
<input type="text" id="place_of_birth" name="place_of_birth" required><br><br>
<label for="location">Location:</label>
<input type="text" id="location" name="location" required><br><br>
<label for="email">Email:</label>
<input type="email" id="email" name="email" required><br><br>
<label for="phone_number">Phone Number:</label>
<input type="tel" id="phone_number" name="phone_number" pattern="[0-9]{4}-[0-9]{4}-[0-9]{4}" required><br><br>
<label for="last_school">Last School:</label>
<input type="text" id="last_school" name="last_school" required><br><br>
<label for="last_school_year">Year of Last School:</label>
<input type="text" id="last_school_year" name="last_school_year" required><br><br>
<label for="last_school_graduated">Did you graduate from the last school?</label><br>
<label for="graduated_yes">Yes</label>
<input type="radio" id="graduated_yes" name="last_school_graduated" value="Yes" required>
<label for="graduated_no">No</label>
<input type="radio" id="graduated_no" name="last_school_graduated" value="No" required><br><br>
<label>Achievement / Certification:</label>
<input type="text" name="achievement[]" required>
<label>Year:</label>
<input type="text" name="achievement_year[]" required><br>
<div id="additional_achievements"></div>
<button type="button" onclick="addAchievement()">Add more</button><br><br>
<label for="summary">Summary:</label><br>
<textarea id="summary" name="summary" rows="4" cols="50" required></textarea><br><br>
<label for="skills">Skills:</label><br>
<textarea id="skills" name="skills" rows="4" cols="50" required></textarea><br><br>
<input type="submit" value="Submit">
<input type="reset" value="Reset">
</form>
<script>
// Function to add more achievement/certification fields
function addAchievement() {
var additionalAchievementDiv = document.getElementById('additional_achievements');
var newAchievementInput = document.createElement('input');
newAchievementInput.type = 'text';
newAchievementInput.name = 'achievement[]';
newAchievementInput.required = true;
additionalAchievementDiv.appendChild(newAchievementInput);
var newYearInput = document.createElement('input');
newYearInput.type = 'text';
newYearInput.name = 'achievement_year[]';
newYearInput.required = true;
additionalAchievementDiv.appendChild(newYearInput);
additionalAchievementDiv.appendChild(document.createElement('br'));
}
</script>
</body>
</html>