-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate.php
More file actions
61 lines (53 loc) · 1.97 KB
/
create.php
File metadata and controls
61 lines (53 loc) · 1.97 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
require_once "app/config.php";
$name = "";
$date = "";
$errorName = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$result = $valid->validateName($_POST["Name"]);
if ($result === true) {
$url = "http://" . $_SERVER['HTTP_HOST'] . "/success_create.php";
$data = array("Name" => addslashes($_POST["Name"]), "Date" => $_POST["Date"]);
$response = $valid->validateSuccess($url, $data);
} else {
$errorName = "Only letters and white space allowed.";
}
}
if (isset($_POST["Date"])) {
$date = htmlentities($_POST["Date"]);
} else {
$date = htmlentities($_GET["date"]);
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Create holiday</title>
<link rel="stylesheet" type="text/css" href="css/main.css">
<link href='https://fonts.googleapis.com/css?family=Open+Sans:300,400,700' rel='stylesheet' type='text/css'>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
</head>
<body>
<?php
if ($valid->validateDate(htmlentities($_GET["date"]), "Y-n-j") || ($_SERVER["REQUEST_METHOD"] == "POST" && $result !== true)) {
?>
<h2 class="create-message">This day will be a holiday - <?php echo $date; ?></h2>
<form class="holiday-form" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']);?>" method="POST">
<p class="error-message"><?php print_r($errorName); ?></p>
<input type="text" name="Name" placeholder="Name holiday" autocomplete="off" />
<input type="hidden" name="Date" value="<?php echo $date; ?>" />
<input class="submit-button" type="submit" value="Save" />
<a class="back-link" href="<?php echo 'http://' . $_SERVER['HTTP_HOST']; ?>">Cancel</a>
</form>
<?php
} else if ($_SERVER["REQUEST_METHOD"] == "POST") {
print_r($response);
} else {
?>
<h2>Something goes wrong.<br /><a href="<?php echo 'http://' . $_SERVER['HTTP_HOST']; ?>">Home page.</a></h2>
<?php
}
?>
</body>
</html>