1
Well, I have a Page and I want to protect it, But with htaccess, everything in the directory is closed. I just want to ask for a Password and Username to enter it, not the other things in the directory.
Here’s the code I already got on it:
<?php
$pagina = "content.html";
if(isset($_POST)){
if($_POST["conteudo"]){
$fopen = fopen($pagina,"w+");
fwrite($fopen,$_POST["conteudo"]);
fclose($fopen);
}
}
?>
<head>
<title>Edit Content Modal</title>
</head>
<br>
<br><br><br>
<form method="post">
<textarea name="conteudo" style="height: 400px; width: 800px; border: none; margin-left: 27%;" placeholder="Type Here the Code..."><?= file_get_contents($pagina); ?></textarea>
<br><br><input style="margin-left: 50%;" type="submit" value="Save Changes"/>
</form>
I want to put only one Password on this page (It will serve to edit another). But only in it, not in the whole directory. I believe the password needs to be stored in a PHP file so no one can find it.
Thank you.
How to set the password and the correct user?
– Hugo Marcelo
I updated take a look now...
– Paulo Costa
In case I set the user as Hugo and password as 1234
– Paulo Costa
Thank you :) I will test.
– Hugo Marcelo
I tested it, but here’s the thing:
– Hugo Marcelo
Strict Standards: Non-static method Authenticator::check() should not be called statically in /home/u146117321/public_html/news/index.php on line 25 Strict Standards: Non-static method Authenticator:::check() should not be called statically in /home/u146117321/public_html/news/index.php on line 40
– Hugo Marcelo
Worked??????
– Paulo Costa
I tested it here and it worked out good :)
– Paulo Costa
I’m trying to fix the code
– Hugo Marcelo
Get my answer! I already updated and corrected for you!
– Paulo Costa
Thanks :) It seems that fixed even.
– Hugo Marcelo
You can learn more about this here: http://php.net/manual/en/features.http-auth.php
– Paulo Costa
Just be careful in using these headers because depending on the browser are ignored and the user can access freely. In some cases remains blocked even by entering correct login and password.
– Daniel Omine
Yep and can use hash functions in tbm passwords.
– Paulo Costa