-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathform.php
More file actions
56 lines (47 loc) · 2.05 KB
/
Copy pathform.php
File metadata and controls
56 lines (47 loc) · 2.05 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
<?php
session_start();
include('db.php');
include('query.php');
$database = new db();
$errors = array();
$data = array();
if (empty($_POST['name']))
$errors['name'] = 'Name is required.';
if(!preg_match("/^[a-zA-Z ]*$/",$_POST['name']))
$errors['name'] = 'Only letters and white space allowed.';
if (empty($_POST['email']))
$errors['email'] = 'Email is required.';
if(!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL))
$errors['email'] = 'Email is invalid.';
if (empty($_POST['number']))
$errors['number'] = 'Number is required.';
if (empty($_POST['photographer']))
$errors['photographer'] = 'Photographer is required.';
if (empty($_POST['date']))
$errors['date'] = 'Date is required.';
if(!empty($_POST['date'])){
$rdate= DateTime::createFromFormat('m/d/Y', $_POST['date'])->format('Y/m/d');
if($rdate>date("Y/m/d")){
$reserved_num = $database->get_row(sprintf(COUNT_RESERVED,$qDate->format('Y/m/d')));
if ($reserved_num["count"] != 0){
$data['success'] = false;
$data['errors'] = 'Date already reserved.';
}
}else
{
$data['success'] = false;
$data['errors'] = 'Date has already passed.';
}
}
if ( ! empty($errors)) {
$data['success'] = false;
$data['errors'] = $errors;
} else {
$rdate= DateTime::createFromFormat('m/d/Y', $_POST['date'])->format('Y/m/d');
$database->others(sprintf(RESERVE_INSERT, $rdate, $_POST['name'], $_POST['email'], $_POST['number'], $_POST['photographer']));
//dito dapat ung queries
$data['success'] = true;
$data['message'] = 'Success!';
}
echo json_encode($data);
?>