user3245390 user3245390 - 3 months ago 18
PHP Question

Get password safely from HTML

I want to get a password from an input form in a safe manner. Originally I was using $_POST[] but I would like a safer method that is reasonably simple and effective.

GetElementById does not seem like a good solution for this but if you think otherwise can you please let me know as I'd like to use it elsewhere if it is.

HTML

<div class="form-group" >
<input type="password" name="password" class="form-control input-lg" placeholder="Password" required>
</div>

Answer

There is nothing wrong with getting a password from $_POST. That is how you access HTTP POST data in PHP. HTTP POST is how login forms work on pretty much every website out there, including your bank's.

But you must do it over an encrypted connection (that is, one that uses TLS). That is the only way to be secure.

Comments