I would make possible that if somebody writes in that imput form a word, PHP redirects him to a page. Is it possible? Can you help me? Thank you alot.
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/index.css">
<title>Magico mondo di Rob</title>
</head>
<body background="img/bg.png">
<div id="paroladiv">
<form>
<center>
<p1> Benvenuto! </p1>
</center>
<center>
<p2 id="parolatext">Inserisci la tua parola magica.</p2>
</center>
<p> </p>
<center>
<form action="" method="POST">
<input id="parola" type="text" name="parola"
placeholder="Parola va qua."><br>
</form>
</center>
</body>
</html>
<?php
if ($_POST['parola'] == google) {
header("Location: http://google.com");
}
?>
You have two things wrong .. Your HEADER
needs to be located at the top of the file to prevent "Headers already sent" error. -- Plus it's always a good idea to throw a DIE
in afterward for good measure.
Second, you need to put your POST
query in quotes as it is a string you are looking for.
Plus as Fred mentioned in comments, you have a stray FORM
tag
<?php
if ( !empty($_POST['parola']) && $_POST['parola'] == 'google') {
header("Location: http://google.com");
die();
}
?>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/index.css">
<title>Magico mondo di Rob</title>
</head>
<body background="img/bg.png">
<div id="paroladiv">
<center>
<p1> Benvenuto! </p1>
</center>
<center>
<p2 id="parolatext">Inserisci la tua parola magica.</p2>
</center>
<p> </p>
<center>
<form action="" method="POST">
<input id="parola" type="text" name="parola" placeholder="Parola va qua."><br>
</form>
</center>
</body>
</html>