[英]isset($_POST['submit']) not working
if condition is not working here. 如果条件在这里不起作用。 i've gone through the earlier solutions but i didn't find a right solution . 我已经通过了较早的解决方案,但是没有找到合适的解决方案。 i couldn't understand the reason . 我不明白原因。 please help me out 请帮帮我
<?php
require'core.inc.php';
require'connect.inc.php';
include 'header.php';
if(isset($_POST['submit'])) {
$query="INSERT INTO college (CollegeName) VALUES ('".$_POST['college']."')";
$result=mysql_query($query) or die(mysql_error());
header('Location:index.php');
}
?>
<form action="insert.php" method="POST">
<input type="text" name="college">
<input type="submit" value="submit" value="Submit">
</form>
<?php include'footer.php';?>
You have two value
here in <input>
, 1 at least should be name
. 您在<input>
有两个value
,至少1应该是name
。 Also there is no <button>
, so remove the Submit</button>
. 也没有<button>
,因此删除Submit</button>
。
<input type="submit" value="submit" value="Submit">Submit</button>
^^^^^ ^^^^^ ^^^^^^^^^^^^^^^
should be 应该
<input type="submit" name="submit" value="Submit"/>
Also, this method is not the best practice for it doesn't work on Internet Explorer. 此外,此方法也不是最佳做法,因为它无法在Internet Explorer上运行。 At the time of writing these i had tried it on IE 8. I find most programmers using this method for one reason or another. 在撰写本文时,我已经在IE 8上进行了尝试。我发现大多数程序员出于某种原因而使用此方法。 My two coin cents would be to check if a POST method has been requested. 我的两分钱是要检查是否已请求POST方法。 Please see how you could approach it below. 请在下面查看如何处理。
if($_SERVER['REQUEST_METHOD'] == 'POST'){ //if a request has been made, do something. Example post or email your data }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.