HTML form string error [closed]

限于喜欢 提交于 2019-12-26 15:17:03

问题


When I click the "Send "Request" button, the query string ?req_flag=0 disappears from the URL. Where am I making a mistake here? I need following URL: localhost/flavourr/send_req.php?req_flag=0&f_e_mail_add=value

<pre>
<form method="get" action="send_req.php?req_flag=0">
                        <input type="text" name="f_e_mail_add" value="Enter email of your friend" onblur='if (this.value == "") {this.value = "Enter email of your friend";}' onfocus='if (this.value == "Enter email of your friend") {this.value = "";}' size="35" />
                        <input type="submit" value="Send Request" />
                            </form></pre>

回答1:


Just add a hidden value as shown below and remove the '?req_flag=0' from the action attribute.

<form method="get" action="send_req.php">
    <input type="text" name="f_e_mail_add" value="Enter email of your friend" size="35" />
    <input type="hidden" id="req_flag" name="req_flag" value="0" />
    <input type="submit" value="Send Request" />
</form>



回答2:


If your page gets that parameter from another source you can't simply transfer a GET parameter from one page to another. You have to find a way for your new form to include that parameter again before submitting the form.

The easiest way is to store it inside a hidden input element like this.

<input type="hidden" name="req_flag" value="<?php echo htmlentities($_GET['req_flag'], ENT_QUOTES, 'utf-8'); ?>" />


来源:https://stackoverflow.com/questions/6779966/html-form-string-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!