在编写和测试此文件后,header("location: url");将无法工作...我不知道该怎么办..。代码如下:
HTML文件
<!doctype html>
<html>
<head>
<title>Program</title>
<link rel="stylesheet" href="../../../../style.css">
</head>
<body>
<div id="main">
<center>
<br><br><br><br>
<a id="question">10a + 4b + 9a + 1b</a>
<br><br><br><br>
<form action"php/q1.php" method="post">
<input type="text" name="a" placeholder="00">a + <input type="text" name="b" placeholder="00">b<br>
<input type="submit" value"Next" id="start">
</form>
<br><br><br><br>
</center>
</div>
</body>
</html>PHP文件
<?php
$a = $_POST['a'];
$b = $_POST['b'];
$final = $a .. "a + " .. $b .. "b";
if ($final = "19a + 5b") {
setcookie("score", 1);
} else {
setcookie("score", 0);
}
header("location: http://www.example.com/go/algabra/simplifying/easy/q2.php");
exit();
?>请不要问我这个代码是用来做什么的!我试着弄清楚,我搜索了各种不同的网站,但我什么也找不到。
PHP版本: PHP 7.1
发布于 2017-10-20 05:13:11
它可能在到达标题行之前出现错误。
$final = $a .. "a + " .. $b .. "b";应该是
$final = $a . "a + " . $b . "b";您可能还想进行此修复:
if ($final = "19a + 5b") {至
if ($final == "19a + 5b") {另外,在html表单中,action一词后面缺少一个等号。
https://stackoverflow.com/questions/46838925
复制相似问题