php表单提交为什么用get方式可以提交而post方式却不可以提交,一直显示:
Notice: Undefined index: form in C:\xampp\htdocs\index.php on line 2;
就是说post方式传值失败,是在不能理解,目录是在c:xampp/htdocs目录下的。
请解答下,非常感激。
html源码:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<form action="index.php" method="post" name="form">
<input type="text" >
<input type="submit" value="click me">
</form>
</body>
</html>
php源码:
1 <?php
2 echo 'hello:'.$_GET['form'];
3 ?>
表单获取的话,你的method是post,则你应该用$_post获取,这样可以了。你的问题应该是中括号里的变量写错了,写的应该是文本框的 name,然而你text类型的文本框没有定义名字........。解决方法就是 在type = "text" 后加个 name="good";然后$_POST['good']
温馨提示:答案为网友推荐,仅供参考