首页 > 解决方案 > How can I hide the value from a input, so that the value is still accesable but won't be displayed?

问题描述

I have a simple input form from the type submit and it contains the value $username:

<form action="index.php" method="POST">
     <input class="submit" type="submit" name="submitbtn" value="'.$username.'">
</form>

How can I hide the value, so that it will not be displayed on index.php, but I still can access this value?

标签: htmlformsinput

解决方案


To hide fields in form from displaying change their type to hidden. Keep in mind that hidden field is just not displayed but anyone can read it/change it with browser devtools.

<form action="index.php" method="POST">
     <input type="hidden" name="user_name" value="'.$username.'">
     <input class="submit" type="submit" name="submitbtn" value="Submit">
</form>

推荐阅读