-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathinsertdoctor.php
100 lines (94 loc) · 2.75 KB
/
insertdoctor.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
89
90
91
92
93
94
95
96
97
98
99
100
<?php
require_once("includes.html");
function newdoctor()
{
include "DBconnect.php";
$did=$_POST['did'];
$name=$_POST['name'];
$gender=$_POST['gender'];
$dob=$_POST['dob'];
$experience=$_POST['experience'];
$specialisation=$_POST['specialisation'];
$contact=$_POST['contact'];
$address=$_POST['address'];
$username=$_POST['username'];
$password=$_POST['password'];
$region=$_POST['region'];
$sql= "INSERT INTO doctor(DID,name,gender,dob,experience,specialisation,contact,address,username,password,region) VALUES('$did','$name','$gender','$dob','$experience','$specialisation','$contact','$address','$username','$password','$region')";
if(mysqli_query($conn,$sql))
{
// echo "<h2> DOCTOR ADDED SUCCESSFULLY!!</h2>";
echo "<script>
swal({
title: 'Successful!',
text: 'DOCTOR ADDED SUCCESSFULLY',
type: 'success'
},
function(){
window.location.href = 'NewDoctor.php';
});
</script>";
// header("Refresh:3;url=NewDoctor.php");
}
else
{
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
}
function checkdid()
{
include 'DBconnect.php';
$did=$_POST['did'];
$sql= "SELECT * FROM doctor WHERE DID = '$did'";
$result=mysqli_query($conn,$sql);
if(mysqli_num_rows($result)!=0)
{
// echo"<b><br>DID ALREADY EXISTS!!";
echo "<script>
swal({
title: 'DID ALREADY EXISTS!!',
text: 'Choose an other DID',
type: 'error'
},
function(){
window.location.href = 'NewDoctor.php';
});
</script>";
}
else
if(isset($_POST['submit']))
{
newdoctor();
}
}
function checkusername()
{
include 'DBconnect.php';
$username=$_POST['username'];
$sql= "SELECT * FROM doctor WHERE username = '$username'";
$result=mysqli_query($conn,$sql);
if(mysqli_num_rows($result)!=0)
{
// echo"<b><br>Username already exists!!";
echo "<script>
swal({
title: 'Username already exists!!',
text: 'Try with an other username',
type: 'error'
},
function(){
window.location.href = 'NewDoctor.php';
});
</script>";
}
else
if(isset($_POST['submit']))
{
checkdid();
}
}
if(isset($_POST['submit']))
{
checkusername();
}
?>