Home » , » How to protect a php file with password by php

How to protect a php file with password by php

Hello everybody, How are you? EID  MUBARAK to all. Today I am going to show you how can you protect a php file by php. If you want the file will only show for you or by entering password, then you can follow the tutorial.

For this work, You must know the basic php. Paste this code in your php file

<?php
$view = header(location: #allcode);
$passMain = yourpasswordhere;
echo "<form method='post' action='#allcode'><input type='password' name='pass'/><input type='submit' value='View file'/></form>";
if($pass==$passMain)
{
echo "$view";
}
else
{
echo "Your password is not correct";
}
?>
<div id="allcode">Your file's all code here</div>

Now save your file and run. Here the $passMain variable contains your main password which will unlock the file. So, change the password with your own.
Good bye and again EID MUBARAK


0 comments:

Post a Comment

Popular Posts

Post Category

Blog Statistics

Now online

Page views
Powered by Blogger.