<?php require_once "includes/config.php"; if (@$_POST['action'] == 'short_url') { $shortUrl = new ShortUrl(); try { $code = $shortUrl->convertUrlToShortCode($_POST['long_url']); include "templates/view.php"; echo '<b>Short URL: </b><p><a target="_blank" href="' . URL . '/redirect/?q=' . $code . '">' . URL . '/redirect/q=' . $code . '</a></p>'; } catch (Exception $e) { echo "<h3>Error!</h3>", $e; exit; } }