0

I am trying to create a login page for a website. The login is for the admin only, so there is only one valid password. The login page itself is a .php file which displays the form, and the form action is a second .php file which is intended to check the password submitted against the correct one. As I don't want to put the correct password in an immediately visible place, I have stored it in a .txt file also on the server (I realize this is far from secure, it is a temporary solution but the one I want for now). The form is here (login.php):

<!DOCTYPE html>
<html>
<body>
<form action="verify.php" method="post">
Password:<input type="text" name="pass">
<input type="submit">
</form>
</body>
</html>

and this is verify.php:

<?php
$real = include("password.txt");
$pass = $_POST("pass");
//might do a session variable here but for now testing with echo to check if it works at all
echo $real;
echo $pass;
?>

OR

<?php
$real = file_get_contents("password.txt");
$pass = $_POST("pass");
//might do a session variable here but for now testing with echo to check if it works at all
echo $real;
echo $pass;
?>

The file will then compare the two to check whether to log in or not.

Not sure which method to use to get the txt file contents, if either of those. Currently, the submit action works, but nothing is echoed at all. If anyone knows what I'm doing wrong, I'd appreciate feedback. Thank you.

Atkeel
  • 3
  • 3
  • [Read this on php.net](http://php.net/manual/en/language.variables.superglobals.php) and you have syntax errors; so [check for them](http://php.net/manual/en/function.error-reporting.php). – Funk Forty Niner Apr 02 '17 at 20:34
  • @Fred-ii- Caught my missing semicolons; do I have other syntax errors? Do I have an issue with the way I called the $_POST superglobal? – Atkeel Apr 02 '17 at 20:44
  • The `$_POST` superglobal is an "array `[]`" and not a "function`()`". See the manual and compare it with what you presently have now. The duplicates to which it was closed with, show you how to check for errors, and in regards to everything posted. Be it the array (syntax error) and folder/file permissions. All of these would have triggered errors using error reporting. Same thing goes for the missing closures for the final statements. – Funk Forty Niner Apr 02 '17 at 20:47
  • @Fred-ii- Thanks, that fixed the echo statement. Still working on the file fetching, you are likely right about permissions being my problem. – Atkeel Apr 02 '17 at 20:51
  • welcome. Yes, that will most likely be the last nail to be driven to put all this together. – Funk Forty Niner Apr 02 '17 at 20:52

0 Answers0