How to hide values in hidden fields?

我与影子孤独终老i 提交于 2019-11-28 06:42:00

问题


I have a simple form in which I have 3 hidden fields, through which I am passing values to another page.

But I don't want anyone to see it through view page source or Fire Bug. I am working with PHP.

<form action=" " method="post" name="push">
    <input type="hidden" name="publisherid" value="createcoolapps"/>
    <input type="hidden" name="username"value="buzzmo"/>
    <input type="hidden" name="pass" value="Javea0615"/>
    <select name="appid">
        <option value="QRScanner">app1</option>
        <option value="app2">app2</option>
        <option value="app3">app3 </option>
        <option value="app4">app4</option>
    </select > 
    <input type="hidden" name="topics" value=" "/>
    Notification Message:<br />
    <textarea style="width:10; height:10;" name="pushmessage"></textarea><br/>
    <input type="submit" value="Push"/>
</form>

回答1:


You can't hide anything in HTML. If it's in the code, anyone can see it. If you need to pass values between pages and keep them hidden, then you need to use Sessions.




回答2:


You can't. If you want to keep something secret from the visitor, don't give it to the visitor's browser.

Store the data on the server and send a token related to that data to the browser instead. Look the data up using the token when the browser submits it back.

You could use sessions for this (although beware of race conditions).




回答3:


You cannot hide values of hidden form elements. You could encrypt it or try to protect other way, but it will be there.




回答4:


As already said, $_SESSIONis the way to go.
If you can't, there ARE ways to protect hidden fields, with a certain amount of security.
The solution is
1. encoding the data and sending the encoded data and the hash,
2. validate if the data has been changed on the 2nd page and de-code it there.

If you are interested, leave a comment and I'll provide some examples.



来源:https://stackoverflow.com/questions/16001849/how-to-hide-values-in-hidden-fields

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