php - allocate text value submitted by a form to a variable after clicking submit button -
i want store text value submitted clicking submit button of form, in variable, can use variable further querying db.
my code:
<? if($submit) { mysql_connect("localhost:3036","root","root");//database connection mysql_select_db("sync"); $order = "insert country (id,country) values ('44','$submit')"; $result = mysql_query($order); if($result){ echo("<br>input data succeed"); } else{ echo("<br>input data fail"); } } ?> <html> <title>form sumit</title> <body> <form method="post" action=""> <input type="text" name="id" value="<?=$submit;?>"/> <input type="submit" name="submit" value="submit"> </form> </body> </html> //in real case, form has elements radio button containing values db query, wanted use selected item form process db query in same page...
thanks in advance
try -
<?php $submit = $_post['id']; if($submit) { //your code here echo $submit; } ?> <html> <title>form sumit</title> <body> <form method="post" action=""> <input type="text" name="id" value="<?php echo $submit; ?>"/> <input type="submit" name="submit" value="submit"> </form> </body> </html>
Comments
Post a Comment