You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
2.0 KiB
PHP

<?php
// Initialize the session
session_start();
// Check if the user is already logged in, if yes then redirect him to welcome page
if(isset($_SESSION["loggedinAdmin"]) && $_SESSION["loggedinAdmin"] === true){
echo "";
}else header("location: ../index.php");
// Include config file
require_once("../model/db.php");
$name = $_POST["name"];
$region = $_POST["region"];
$description = $_POST["description"];
if(!is_null($name)){
$conn = $pdo;
try {
$sql = "INSERT INTO brewery ( name, region, description ) values ( '$name', '$region', '$description' );";
echo $sql;
$conn->exec($sql);
} catch (PDOException $e) {
echo "Error!";
}
}
// header("location: ../insertWhat.php");
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Insert Brewery</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<style>
body{ font: 14px sans-serif; }
.wrapper{ width: 360px; padding: 20px; }
</style>
</head>
<body>
<div class="wrapper">
<h2>Insert Brewery</h2>
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" method="post">
<div class="form-group">
<label>Name of Brewery</label>
<input type="text" name="name" class="form-control">
</div>
<div class="form-group">
<label>Region</label>
<input type="text" name="region" class="form-control">
</div>
<div class="form-group">
<label>Description</label>
<textarea rows="4" cols="50" name="description" class="form-control"></textarea>
</div>
<div class="form-group">
<input type="submit" class="btn btn-primary" value="Submit">
<a class="btn btn-link ml-2" href="insertWhat.php">Cancel</a>
</div>
</form>
</div>
</body>
</html>