<?php
include ("apps/controller/database.php"); include ("header.php");
//Connect to the DB $database->connect(); //Check the url has been set
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$url = isset($_POST['url']) ? $database->escape($_POST['url']) : false;
//$url = isset($_POST['url']) ? $database->escape($_POST['url']) : '';
//This is optional ;)
$password = isset($_POST['password']) ? $database->escape($_POST['password']) : '';
//Okay, now we've figured out if they've set the url, let's add it to the DB
if (isset($url)) {
$id = md5(uniqid());
$res = $database->query("INSERT INTO urls (url,pass,key) VALUES('".$url."','".$password."','".$id."')");
echo '<br /><br /><div id="both" class="types both"><a href="http://localhost/view.php?id=' .
$id . '">http://localhost/view.php?id=' . $id . '</a></div>';
}
//Close the DB
$database->close();
}else
{
echo '<br /><br /><div id="err" class="notification error"><a class="close" href="#" alt="close" title="Close this notification"> </a> You cannot view this URL directly. Please create a url.</div>';
}
$database->close();
私のMYSQL構造は次のとおりです:id、url、views、keys