35787-vm/redirect.php
Flatlogic Bot 9d71ce33bd qwe1.0
2025-11-17 07:30:48 +00:00

23 lines
423 B
PHP

<?php
require_once 'db/config.php';
$short_code = $_GET['code'] ?? null;
if (!$short_code) {
header("Location: /");
exit;
}
$pdoconnection = db();
$stmt = $pdoconnection->prepare("SELECT original_url FROM links WHERE short_code = ?");
$stmt->execute([$short_code]);
$link = $stmt->fetch();
if ($link) {
header("Location: " . $link['original_url']);
exit;
} else {
header("Location: /");
exit;
}