-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconnect.php
More file actions
61 lines (53 loc) · 1.73 KB
/
connect.php
File metadata and controls
61 lines (53 loc) · 1.73 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
<?php
if (isset($_POST['submit'])) {
if (isset($_POST['Name']) && isset($_POST['password']) &&
isset($_POST['DoctorId']) && isset($_POST['field'])){
$Name = $_POST['Name'];
$password = $_POST['password'];
$DoctorId = $_POST['DoctorId'];
$field = $_POST['field'];
$host = "localhost";
$dbUsername = "root";
$dbPassword = "";
$dbName = "test";
$conn = new mysqli($host, $dbUsername, $dbPassword, $dbName);
if ($conn->connect_error) {
die('Could not connect to the database.');
}
else {
$Select = "SELECT DoctorId FROM doctors WHERE DoctorId = ? LIMIT 1";
$Insert = "INSERT INTO doctors(Name, DoctorId, password, field) values(?, ?, ?, ?)";
$stmt = $conn->prepare($Select);
$stmt->bind_param("s", $email);
$stmt->execute();
$stmt->bind_result($resultEmail);
$stmt->store_result();
$stmt->fetch();
$rnum = $stmt->num_rows;
if ($rnum == 0) {
$stmt->close();
$stmt = $conn->prepare($Insert);
$stmt->bind_param("ssss",$Name, $DoctorId, $password, $field);
if ($stmt->execute()) {
echo "New record inserted sucessfully.";
}
else {
echo $stmt->error;
}
}
else {
echo "Someone already registers using this DoctorId.";
}
$stmt->close();
$conn->close();
}
}
else {
echo "All field are required.";
die();
}
}
else {
echo "Submit button is not set";
}
?>