本文介绍了PHP中的HTML表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在用php脚本编写html表单代码
这里是
如果一个表单是 method =GET(这是默认),然后提交它将清除操作中现有的查询字符串。
将数据存储在隐藏输入中。
<?php
$ problem_code =STR;
?>
< form name =submit-buttonaction =/ codejudge / submit.php>
< input type =hiddenname =idvalue =<?php echo htmlspecialchars($ problem_code);?>>
< button type =submit>提交< / button>
< / form>
i am writing html form code with in php script
here it is
<?php $problem_code="STR"; echo '<form name="submit-button" action="/codejudge/submit.php?id='.$problem_code.'">'; echo '<button type="submit" >Submit</button>'; echo "</form>"; ?>But after submitting url look like this localhost/codejudge/submit.php ?but it should be like this localhost/codejudge/submit.php?id=STR
解决方案If a form is method="GET" (which is the default), as this one is, then submitting it will erase the existing query string in the action.
Store the data in a hidden input instead.
<?php $problem_code="STR"; ?> <form name="submit-button" action="/codejudge/submit.php"> <input type="hidden" name="id" value="<?php echo htmlspecialchars($problem_code); ?>"> <button type="submit">Submit</button> </form>
这篇关于PHP中的HTML表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!