从HTML安全地获取密码

时间:2016-08-23 20:54:36

标签: php html

我希望以安全的方式从输入表单中获取密码。最初我使用的是$ _POST [],但我想要一种更安全的方法,这种方法相当简单有效。

GetElementById似乎不是一个很好的解决方案,但如果您认为不是,请告诉我,因为我想在其他地方使用它,如果是的话。

HTML

<form id="form1" name="form1" method="POST" action="getData">
       <h1>Quick Query</h1>
        <div class="floating-placeholder">
            <input id="origin" name="origin" type="text" placeholder="Number" value="5"/>
            <label for="origin"></label>
        </div>
        <div class="floating-placeholder">
            <input id="destination" name="destination" type="text" placeholder="Number" value="4"/>
            <label for="destination"></label>
        </div>
        <div>
            <select name="transitType" id="transitType">
              <option>drive</option>
              <option>cycling</option>
              <option>transit</option>
            </select>
        </div>
        <label>
            <input type="submit" />
         </label>
    </form>

1 个答案:

答案 0 :(得分:4)

$_POST获取密码没有任何问题。这就是您在PHP中访问HTTP POST数据的方式。 HTTP POST是登录表单在几乎所有网站上的工作方式,包括您的银行。

但是必须通过加密连接(即使用TLS的连接)执行此操作。这是唯一的安全方式。