34 lines
858 B
PHP
34 lines
858 B
PHP
<?php
|
|
session_start();
|
|
if (!isset($_SESSION['user_id'])) {
|
|
header('Location: ../login.php');
|
|
exit;
|
|
}
|
|
require_once '../db/config.php';
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
|
$slug = $_POST['slug'];
|
|
$offer_url = $_POST['offer_url'];
|
|
$user_id = $_SESSION['user_id'];
|
|
|
|
$pdo = db();
|
|
$stmt = $pdo->prepare("INSERT INTO campaigns (user_id, slug, offer_url) VALUES (?, ?, ?)");
|
|
$stmt->execute([$user_id, $slug, $offer_url]);
|
|
|
|
header('Location: dashboard.php');
|
|
exit;
|
|
}
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html>
|
|
<head><title>Create Campaign</title></head>
|
|
<body>
|
|
<h1>Create Campaign</h1>
|
|
<form method="POST">
|
|
Slug (URL path): <input type="text" name="slug" required><br>
|
|
Offer URL: <input type="url" name="offer_url" required><br>
|
|
<button type="submit">Create</button>
|
|
</form>
|
|
</body>
|
|
</html>
|