Codice PHP:
<?php
if ($_SERVER["REQUEST_METHOD"] === "POST"){
$logout = test_input($_POST['logout']);
$server = 'localhost';
$utente = 'providerweb';
$password = '***********';
$database = 'my_providerweb';
}
// define variables and set to empty values
if ($_SERVER["REQUEST_METHOD"] === "POST") {
$email = test_input( $_POST['email']);
$pass = test_input($_POST['password']);
}
$server = 'localhost';
$utente = 'providerweb';
$password = '********';
$database = 'my_providerweb';
$email = $_POST['email'];
$pass = $_POST['password'];
$mysqli = mysqli_connect("localhost",$utente,$password,$database);
if (mysqli_connect_errno()) {
header('Location: /');
}
mysqli_multi_query($mysqli,"SELECT email, password FROM login");
if(!mysqli_multi_query($mysqli,"SELECT email, password FROM login")){
header('Location: login.php');
}else{
header('Location: blog.php');
}
mysqli_multi_query($mysqli,"INSERT INTO login(email,password)VALUES($email,$pass)");
if(!mysqli_multi_query($mysqli,"INSERT INTO login(email,password)VALUES($email,$pass)")){
header('Location: /');
}
if ($_SERVER["REQUEST_METHOD"] === "POST") {
$title = test_input($_POST["title"]);
$title2 = test_input($_POST["title2"]);
$title3 = test_input($_POST["title3"]);
$foto = test_input($_POST["foto"]);
$foto2 = test_input($_POST["foto2"]);
$foto3 = test_input($_POST["foto3"]);
$content = test_input($_POST['content']);
$tag = test_input($_POST["tag"]);
$tag2 = test_input($_POST["tag2"]);
$tag3 = test_input($_POST["tag3"]);
$tag4 = test_input($_POST["tag4"]);
$tag5 = test_input($_POST["tag5"]);
$tag6 = test_input($_POST["tag6"]);
$permalink = test_input($_POST["permalink"]);
$permalink2 = test_input($_POST["permalink2"]);
$permalink3 = test_input($_POST["permalink3"]);
$permalink4 = test_input($_POST["permalink4"]);
$permalink5 = test_input($_POST["permalink5"]);
$permalink6 = test_input($_POST["permalink6"]);
$server = 'localhost';
$utente = 'providerweb';
$password = '************';
$database = 'my_providerweb';
mysqli_multi_query($mysqli,"INSERT INTO blog(title,title2,title3,foto,foto2,foto3,content)
VALUES($title,$title2,$title3,$foto,$foto2,$foto3,$content,$tag)");
mysqli_multi_query($mysqli,"INSERT INTO tag(tag,tag2,tag3,tag4,tag5,tag6)
VALUES($tag,$tag2,$tag3,$tag4,$tag5,$tag6)");
mysqli_multi_query($mysqli,"INSERT INTO permalink(permalink,permalink2,permalink3,permalink4,permalink5,permalink6)
VALUES($permalink,$permalink2,$permalink3,$permalink4,$permalink5,$permalink6)");
if(!mysqli_multi_query($mysqli,"INSERT INTO permalink(permalink,permalink2,permalink3,permalink4,permalink5,permalink6)
VALUES($permalink,$permalink2,$permalink3,$permalink4,$permalink5,$permalink6)")){
header('Location: blog.php');
}
mysqli_close($mysqli);
}else{
header('Location: login.php');
}
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?>