-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunction.php
125 lines (106 loc) · 3.41 KB
/
function.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<?php
function idExists($conn,$ID){
$sql = "SELECT * FROM babysitter where ID = ? ;";
$stmt = mysqli_stmt_init($conn);
if(!mysqli_stmt_prepare($stmt,$sql)){
header("location:signUpAsBabysitter.php?error=stmtfailed");
exit();}
mysqli_stmt_bind_param($stmt,"i",$ID);
mysqli_stmt_execute($stmt);
$resultData = mysqli_stmt_get_result($stmt);
if($row = mysqli_fetch_assoc($resultData )){
return $row;
}
else{
$result = false;
return $result;
}
mysqli_stmt_close($stmt);
}
function emailExists($conn,$email){
$sql = "SELECT * FROM babysitter where Email = ?;";
$stmt = mysqli_stmt_init($conn);
if(!mysqli_stmt_prepare($stmt,$sql)){
header("location:signUpAsBabysitter.php?error=stmtfailed");
exit();}
mysqli_stmt_bind_param($stmt,"s",$email);
mysqli_stmt_execute($stmt);
$resultData = mysqli_stmt_get_result($stmt);
if($row = mysqli_fetch_assoc($resultData )){
return $row;
}
else{
$result = false;
return $result;
}
mysqli_stmt_close($stmt);
}
function phoneExists($conn,$phone){
$sql = "SELECT * FROM babysitter where Phone = ?;";
$stmt = mysqli_stmt_init($conn);
if(!mysqli_stmt_prepare($stmt,$sql)){
header("location: signUpAsBabysitter.php?error=stmtfailed");
exit();}
mysqli_stmt_bind_param($stmt,"i",$phone);
mysqli_stmt_execute($stmt);
$resultData = mysqli_stmt_get_result($stmt);
if($row = mysqli_fetch_assoc($resultData )){
return $row;
}
else{
$result = false;
return $result;
}
mysqli_stmt_close($stmt);
}
function phoneinvalid($conn,$phone){
$result;
if(! preg_match('/^[0-9]{10}+$/', $phone)){
$result = true;}
else{
$result = false;
}
return $result;
}
function IDinvalid($conn,$ID){
$result;
if(! preg_match('/^[0-9]{8}+$/', $ID)){
$result = true;}
else{
$result = false;
}
return $result;
}
function ageinvalid($conn,$age){
$result;
if(! preg_match('/^[0-9]{2}+$/', $age)){
$result = true;}
else{
$result = false;
}
return $result;
}
function createUser($conn,$FirstName,$LastName,$ID,$age,$email,$gender,$photo,$psw,$phone,$city,$bio){
$sql = "INSERT INTO babysitter(FirstName,LastName,ID,Age,Gendre,Email,Photo,Pass,Phone,City,Bio) VALUES(?,?,?,?,?,?,?,?,?,?,?);";
$stmt = mysqli_stmt_init($conn);
if(! mysqli_stmt_prepare($stmt,$sql)){
header("location:signUpAsBabysitter.php?error=stmtfailed");
exit();}
mysqli_stmt_bind_param($stmt,"ssiissssiss",$FirstName,$LastName,$ID,$age,$email,$gender,$photo,$psw,$phone,$city,$bio);
mysqli_stmt_execute($stmt);
mysqli_stmt_close($stmt);
header("location: signUpAsBabysitter.php?error=none");
exit();
}
function createRequest($conn,$kidsNames,$KidsAges,$service,$otherServices,$date,$Stime,$Etime){
$sql = "INSERT INTO request list(KidsName,KidsAges,Services,OtherServices,Dates,StartTime,EndTime) VALUES(?,?,?,?,?,?,?);";
$stmt = mysqli_stmt_init($conn);
if(! mysqli_stmt_prepare($stmt,$sql)){
header("location:jobRequest.php?error=stmtfailed");
exit();}
mysqli_stmt_bind_param($stmt,"ssissss",$kidsNames ,$KidsAges,$service,$otherServices,$date,$Stime,$Etime);
mysqli_stmt_execute($stmt);
mysqli_stmt_close($stmt);
header("location:jobRequest.php?error=none");
exit();
}