[英]PHP submit button not working.
<?php
if(isset($_POST['submit'])){
header('Location: http://www.rate.ee');
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>
</title>
</head>
<body>
<input type="submit" name="submit" id="submit" class="button" value="Submit"/>
</body>
</html>
This is my code. 这是我的代码。 Very simple, isn't it. 很简单,不是吗。 But it doesn't work and I don't get it.. I always thought that PHP only executes when I load the page, but the other page where I use same code works very well without JS.. 但它不起作用,我不明白..我一直认为PHP只在我加载页面时执行,但是我使用相同代码的另一个页面在没有JS的情况下工作得非常好。
You need to wrap your button in a <form>
tag: 您需要将按钮包装在<form>
标记中:
<form action="" method="post">
<input type="submit" name="submit" id="submit" class="button" value="Submit"/>
</form>
You need a form surrounding the input. 您需要一个围绕输入的表单。
<body>
<form action="welcome.php" method="post">
<input type="submit" name="submit" id="submit" class="button" value="Submit"/>
</form>
</body>
</html>
You have no form tag and even if you did it would need the method="post" attribute. 您没有表单标记,即使您这样做,也需要method =“post”属性。
<form method="post" action="<?php echo $_SERVER[PHP_SELF]?>">
<input type="submit" name="submit" id="submit" class="button" value="Submit"/>
</form>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.