|
8 | 8 | <body> |
9 | 9 | <h1>Validation Result</h1> |
10 | 10 | <?php |
11 | | - $name = $email = $date = $dateInput = ""; |
12 | | - $nameErr = $emailErr = $dateErr = $dateInputErr = ""; |
| 11 | + $name = $email = $date = $dateInput = $time = $timeInput = $datetimeInput = $datetimeLocalInput = $month = $week = $number = $range = $color = ""; |
| 12 | + $nameErr = $emailErr = $dateErr = $dateInputErr = $timeErr = $timeInputErr = $datetimeInputErr = $datetimeLocalInputErr = $monthErr = $weekErr = $numberErr = $rangeErr = $colorErr = ""; |
13 | 13 | if ($_SERVER["REQUEST_METHOD"] == "POST") { |
14 | 14 | if (empty($_POST["name"])) { |
15 | 15 | $nameErr = "Name is required"; |
|
44 | 44 | $timeInputErr = "Invalid time format"; |
45 | 45 | } |
46 | 46 | } |
| 47 | + |
| 48 | + if (empty($_POST["datetimeInput"])) { |
| 49 | + $datetimeInputErr = "Datetime Input is required"; |
| 50 | + } else { |
| 51 | + $datetimeInput = htmlspecialchars($_POST["datetimeInput"]); |
| 52 | + } |
| 53 | + |
| 54 | + if (empty($_POST["datetimeLocalInput"])) { |
| 55 | + $datetimeLocalInputErr = "Datetime Local Input is required"; |
| 56 | + } else { |
| 57 | + $datetimeLocalInput = htmlspecialchars($_POST["datetimeLocalInput"]); |
| 58 | + } |
| 59 | + |
| 60 | + if (empty($_POST["month"])) { |
| 61 | + $monthErr = "Month is required"; |
| 62 | + } else { |
| 63 | + $month = htmlspecialchars($_POST["month"]); |
| 64 | + } |
| 65 | + |
| 66 | + if (empty($_POST["week"])) { |
| 67 | + $weekErr = "Week is required"; |
| 68 | + } else { |
| 69 | + $week = htmlspecialchars($_POST["week"]); |
| 70 | + } |
| 71 | + |
| 72 | + if (empty($_POST["number"])) { |
| 73 | + $numberErr = "Number is required"; |
| 74 | + } else { |
| 75 | + $number = htmlspecialchars($_POST["number"]); |
| 76 | + } |
| 77 | + |
| 78 | + if (empty($_POST["range"])) { |
| 79 | + $rangeErr = "Range is required"; |
| 80 | + } else { |
| 81 | + $range = htmlspecialchars($_POST["range"]); |
| 82 | + } |
| 83 | + |
| 84 | + if (empty($_POST["color"])) { |
| 85 | + $colorErr = "Color is required"; |
| 86 | + } else { |
| 87 | + $color = htmlspecialchars($_POST["color"]); |
| 88 | + } |
47 | 89 | } |
48 | 90 | echo "<p>Name: $name</p>"; |
49 | 91 | if ($nameErr) { |
|
61 | 103 | if ($dateInputErr) { |
62 | 104 | echo "<p style='color:red;'>$dateInputErr</p>"; |
63 | 105 | } |
64 | | - |
| 106 | + echo "<p>Time: $time</p>"; |
| 107 | + if ($timeErr) { |
| 108 | + echo "<p style='color:red;'>$timeErr</p>"; |
| 109 | + } |
| 110 | + echo "<p>Time Input: $timeInput</p>"; |
| 111 | + if ($timeInputErr) { |
| 112 | + echo "<p style='color:red;'>$timeInputErr</p>"; |
| 113 | + } |
| 114 | + echo "<p>Datetime Input: $datetimeInput</p>"; |
| 115 | + if ($datetimeInputErr) { |
| 116 | + echo "<p style='color:red;'>$datetimeInputErr</p>"; |
| 117 | + } |
| 118 | + echo "<p>Datetime Local Input: $datetimeLocalInput</p>"; |
| 119 | + if ($datetimeLocalInputErr) { |
| 120 | + echo "<p style='color:red;'>$datetimeLocalInputErr</p>"; |
| 121 | + } |
| 122 | + echo "<p>Month: $month</p>"; |
| 123 | + if ($monthErr) { |
| 124 | + echo "<p style='color:red;'>$monthErr</p>"; |
| 125 | + } |
| 126 | + echo "<p>Week: $week</p>"; |
| 127 | + if ($weekErr) { |
| 128 | + echo "<p style='color:red;'>$weekErr</p>"; |
| 129 | + } |
| 130 | + echo "<p>Number: $number</p>"; |
| 131 | + if ($numberErr) { |
| 132 | + echo "<p style='color:red;'>$numberErr</p>"; |
| 133 | + } |
| 134 | + echo "<p>Range: $range</p>"; |
| 135 | + if ($rangeErr) { |
| 136 | + echo "<p style='color:red;'>$rangeErr</p>"; |
| 137 | + } |
| 138 | + echo "<p>Color: $color</p>"; |
| 139 | + if ($colorErr) { |
| 140 | + echo "<p style='color:red;'>$colorErr</p>"; |
| 141 | + } |
65 | 142 | ?> |
66 | 143 | </body> |
67 | 144 |
|
|
0 commit comments