-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconnect.php
More file actions
46 lines (29 loc) · 878 Bytes
/
connect.php
File metadata and controls
46 lines (29 loc) · 878 Bytes
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
<?php
$conn = mysqli_connect("localhost", "root", "", "user");
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$name = $_POST["name"];
$age = $_POST["age"];
$weight = $_POST["weight"];
$email = $_POST["email"];
$file_name = '';
if (isset($_FILES['pdf_file']['name']))
{
$file_name = $_FILES['pdf_file']['name'];
$file_tmp = $_FILES['pdf_file']['tmp_name'];
move_uploaded_file($file_tmp,"./pdf/".$file_name);
}
$sql = "INSERT INTO registration (name, age, weight, email, pdf_file) VALUES ('$name', '$age', '$weight', '$email', '$file_name')";
$stmt = $conn->prepare($sql);
// $stmt->bind_param("siis", $name, $age, $weight, $email);
$result = $stmt->execute();
if ($result) {
header("Location: userlist.php");
exit;
} else {
echo "There was an error adding the user.";
}
$stmt->close();
$conn->close();
?>