php 如何在php中将文本框值设置为变量并用按钮发布
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14103100/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to get text box value to variable in php and post it with button
提问by user1939816
i have a code
我有一个代码
<form action="index.php" method="post">
<input type="text" name="jam" />
<input type="submit" name="submit" value="Translate" />
</form>
<?php
$conn = mysql_connect ("localhost", "root","") or die (mysql_error());
mysql_set_charset('utf8',$conn);
mysql_select_db ("movedb");
$jam = $_POST['jam'];
$sql = mysql_query("select * from WORD where ENGLISH like '$jam%' Limit 15");
while ($row = mysql_fetch_array($sql)){
echo ' '.$row['ENGLISH'];
echo ' - '.$row['SINHALA'];
echo '<br/>';
}
?>
i want to post that text value like index.php?=text=(text box value here)
我想发布像 index.php?=text=(text box value here) 这样的文本值
and i want to get that submited to $jam
我想把它提交给 $jam
采纳答案by SeanWM
Form method should be getnot post.
表格方法应该get不是post。
Also, remove the >from your action. Small typo.
另外,>从您的操作中删除。小错别字。
Try:
尝试:
<form action="index.php" method="get">
<input type="text" name="jam" />
<input type="submit" name="submit" value="Translate" />
</form>
Then you can do: $jam = $_GET['jam'];
然后你可以这样做: $jam = $_GET['jam'];

