如何获得文本框值变量在php和post它与按钮


How to get text box value to variable in php and post it with button

我有一个代码

  <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/>';
    }

?>

我想张贴文本值像index.php?=text=(这里的文本框值)

我想把它提交到$jam

表单方法应该是get而不是post

同时,从你的动作中移除>。小错误。

试题:

<form action="index.php" method="get">  
<input type="text" name="jam" />
<input type="submit" name="submit" value="Translate" />
</form>

你可以这样做:$jam = $_GET['jam'];