-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathposttimes.php
41 lines (39 loc) · 1.12 KB
/
posttimes.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
<?php
if(!empty($_GET)){
echo "Bruh not here fool";
exit();
}
print_r($_POST);
if(!empty($_POST)){
if(empty($_POST['rtime'])||empty($_POST['name'])){
http_response_code(400);
echo "Incomplete request";
exit();
}else if (!(is_string($_POST['name'])&&strlen($_POST['name'])==3)){
http_response_code(400);
echo "The name is not valid";
exit();
}else if(!is_numeric($_POST['rtime'])){
http_response_code(400);
echo "The time is not valid";
exit();
}else{
$rtime=$_POST['rtime'];
$name=$_POST['name'];
$connection=mysqli_connect("localhost","root","","JSScores");
if(!$connection){
http_response_code(503);
echo mysqli_connect_error();
exit();
}else{
$result=$connection->query("INSERT INTO scores (rtime,uname) VALUES ($rtime,\"$name\");");
if(!$result){
http_response_code(500);
echo $connection->error;
exit();
}else{
echo "Success";
}
}
}
}