可能吗?PHP
如果有人以这种输入形式写一个单词,PHP会将他重定向到一个页面。可能吗?你能帮助我吗?多谢各位可能吗?PHP,php,if-statement,Php,If Statement,如果有人以这种输入形式写一个单词,PHP会将他重定向到一个页面。可能吗?你能帮助我吗?多谢各位 <!DOCTYPE html> <html> <head> <link rel="stylesheet" type="text/css" href="css/index.css"> <title>Magico mondo di Rob</title> </head> <body backgrou
<!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");
}
?>
罗布魔术师
本维努托!
这是一个神奇的世界。
你有两件事做错了。。您的标题
需要位于文件顶部,以防止出现“标题已发送”错误。-另外,为了更好的测量,在之后扔一个模具总是一个好主意
其次,您需要将POST
查询放在引号中,因为它是您要查找的字符串
另外,正如Fred在评论中提到的,您有一个零散的表单
标签
<?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>
罗布魔术师
本维努托!
这是一个神奇的世界。
使用JavaScript可以轻松实现这一点。我想你可以很容易地在谷歌上找到它。如果你愿意,意大利语也有很多结果!我真的不知道我应该在谷歌上搜索什么词。JavaScript中是否有我可以查找的特定函数?if($\u POST['parola']==google)
将向您抛出一个未定义常量google
通知。这不是有效的HTML标记标记
。
.si@LelioFaieta definitivamente amico mio!忘记了杂散的
标签;-)最好使用isset()
/!empty()
&&equals,用于POST arrayhahaha!!抓到弗雷德了EDITEDWell它仍然不起作用。另外,
和
都不是有效的HTML标记,我记得最后一次。;-)他们可能打算使用
和
@Jediah,这是应该的。问题是,您的.php
文件是在安装了php的web服务器上运行的,还是作为file:///file.xxx
?而不是http://localhost/file.xxx
?这里有两种不同的动物。