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.
34 lines
746 B
PHP
34 lines
746 B
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["loggedin"]) && $_SESSION["loggedin"] == false){
|
|
header("location: ../index.php");
|
|
exit;
|
|
}
|
|
|
|
// Include config file
|
|
require_once("../model/db.php");
|
|
|
|
$what = key($_POST);
|
|
$item = $_POST[$what];
|
|
$id = $_SESSION["id"];
|
|
|
|
if ($what == "beer"){
|
|
$from_id = "beer_id";
|
|
$from="list";
|
|
} else {
|
|
$from_id = "brewery_id";
|
|
$from="follow";
|
|
}
|
|
|
|
$conn = $pdo;
|
|
try {
|
|
$sql = "INSERT INTO $from ( user_id, $from_id) values ( $id, $item );";
|
|
echo $sql;
|
|
$conn->exec($sql);
|
|
} catch (PDOException $e) {
|
|
echo "Error in $from: Not Found";
|
|
}
|
|
header("location: ../$what.php?id=$item"); |