-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinsert_cat.php
More file actions
49 lines (43 loc) · 1.13 KB
/
Copy pathinsert_cat.php
File metadata and controls
49 lines (43 loc) · 1.13 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
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<base target="_top">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="language" content="english">
<title>Home Page</title>
<link rel="shortcut icon" href="favicon.ico">
</head>
<body>
<?php
/**
* @author Bob S. <Tips@TechnoWizardBob.com>
* @copyright Copyright (c) 2022, Bob S.
* @license MIT
*/
require "db.inc.php";
$cat = $_POST['cat'] ?? false;
if ($cat === false) {
?>
<form method="POST">
<label for="cat">Enter Name of Category</label>
<input type="text" name="cat" id="cat" maxlength="100"/>
<input type="submit" />
</form>
<?php
} else {
try {
$sql = "INSERT INTO cats (category) VALUES (:cat)";
$pdostmt = $pdo->prepare($sql);
if (! $pdostmt === false) {
$pdostmt->execute(["cat"=>$cat]);
}
} catch (PDOException $e) {
echo $e->getMessage();
}
echo "<a href=\"index.php".bust()."\">Back to Home Page</a>";
$_SESSION['last'] = false;
}
?>
</body>
</html>