开发者

PHP:HTML Do Pre-filled form values get overriden?

开发者 https://www.devze.com 2023-03-21 11:24 出处:网络
If in a form i set 开发者_高级运维<input type = \'text\' name = \'entry\' value =\'default_text\'/>

If in a form i set

开发者_高级运维<input type = 'text' name = 'entry' value ='default_text'/>

And a user enters 'foo' in place of 'default_text' is this enough to make $_POST['entry'] become 'foo' instead of 'default_text'?

If not how do i make that happen?


If someone enters text into this input:

<input type = 'text' name = 'entry' value ='default_text'/>

PHP will receive the new text in $_POST/$_GET/$_REQUEST etc. and not the default (so, to answer your question, yes that is enough).


Yes, if the <input type="text" /> element is placed within a <form method="post"> element which also contains an <input type="submit" /> element to send the data:

<form method="post" action="/url/where/form/will/be/sent.php">
    <input type = 'text' name = 'entry' value ='default_text'/>
    <input type = 'submit' />
</form>

Of course, data will only be sent when the form is submitted. What happened wrong in your code?

0

精彩评论

暂无评论...
验证码 换一张
取 消