本文介绍了HTML 表单提交到 PHP 脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在制作一个 HTML 表单.我希望结果出现在 PHP 脚本中.
<br/>名称=网站字符串"<option value="" selected="selected"></option><option VALUE="abc">ABC</option><option VALUE="def">def</option><option VALUE="hij">hij/选项></选择><input type="submit" name="website_string" ></表单>
问题是我无法获得传递给 PHP 的值.如果我使用价值:
它总是传递引号中的文本.在这种情况下
选择"
.如何从选项中传递其中一个字符串?
解决方案
试试这个:
您的选择控件和提交按钮都具有相同的
name
属性,因此最后一个使用的是您单击它时的提交按钮.抛开所有其他语法错误.
check.php
check.php
关于使用原始
$_POST
数据的强制性免责声明.清理您将在应用程序逻辑中实际使用的任何内容.
I am making an HTML form. I want the results to appear in the PHP script.
<form action="chk_kw.php" method="post"> <br />
<select> name="website_string"
<option value="" selected="selected"></option>
<option VALUE="abc"> ABC</option>
<option VALUE="def"> def</option>
<option VALUE="hij"> hij/option>
</select>
<input type="submit" name="website_string" >
</form>
The problem is I cannot get the value passed to the PHP. if I use value:
<INPUT TYPE="submit" name="website_string" value="selected" >
It always passes the text in the quotes. In this case
"selected"
. How do I pass one of the strings from the option?
解决方案
Try this:
<form method="post" action="check.php">
<select name="website_string">
<option value="" selected="selected"></option>
<option VALUE="abc"> ABC</option>
<option VALUE="def"> def</option>
<option VALUE="hij"> hij</option>
</select>
<input TYPE="submit" name="submit" />
</form>
Both your select control and your submit button had the same
name
attribute, so the last one used was the submit button when you clicked it. All other syntax errors aside.
check.php
check.php
<?php
echo $_POST['website_string'];
?>
这篇关于HTML 表单提交到 PHP 脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!