How to get the text field value of a variable in php and place it using a button

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 publish this text value like index.php? = text = (here is the value of the text field)

and I want to get sent in $ jam

+4
source share
1 answer

The form method should be get not post .

Also remove > from your action. A little 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'];

+3
source

All Articles