Jump to content
xisto Community
Sign in to follow this  
evion

A Php Loginbox On Your Webpage Is it possible?

Recommended Posts

You know how when you password protect a page/directory, and try to access that page/directory, you would be prompted to type in your username and password? Is it possible for me to input some code on a page so that the person types his uername and password on the webpage itself like those loginboxes which you seein many websites. I know i sound kinda stupid but I was just hoping that it could work.I would appreciate all your help! ;)

Share this post


Link to post
Share on other sites

It's not a tutorial so I moved your post here to the "What Is.." forum. Use the tutorial forum for tutorials only and ask for help and for "new" tutorials in the respectice forums. ;)Nils

Share this post


Link to post
Share on other sites

To do this, you need a database to store the password and usernames of your members. But I'm not going to show you that here, because there are a lot of tutorials online that teaches you that. I am just going to give you a script that can only authorize one username and password.

<?phpif ($form == "yes")  // form sent{ if ($_POST[username] == admin && $_POST[password] == yourpasswordhere)  // If the username entered is admin and the password is yourpasswordhere {  header("Location: member.php");  // Go to members page } else  // If username or password is wrong {  echo "Wrong Username or Password. Please try again.<br>"; }}?><html><head><title>Login</title></head><body><form method="POST" action="<? echo $php_self ?>?form=yes"><center><p><font size="7">Members Login</font><br></p>  <table border="0" width="40%">    <tr>      <td width="50%">      <p>Username:</p>      </td>      <td width="50%">      <p><input type="text" name="username" size="20"></p>      </td>    </tr>    <tr>      <td width="50%">      <p>Password:</p>      </td>      <td width="50%">      <p><input type="password" name="password" size="20"></p>      </td>    </tr>  </table>  <p align="center">  <input type="submit" value="Login" name="submit"></p></form></body></html>

Share this post


Link to post
Share on other sites

i think the safest & best way would be to use htaccessthat will protect your folder. once you enter the password, you'd be able to view the files inside the folder. you can use this for all purposes: a hidden website or just a hidden storage for files you want to access files from everywhere.if you just want to prohibit access to your website, you can use an index.php file. you can store your password hardcoded if it's not very imporant. you can store an md5 hash of it if you want it to be safer, or an md5 hash in a database to go really safe. if you want, i can provide you with a login page that uses a database & an md5 hashed password. even if a hacker would be scanning your traffic, he wouldn't be able to get your password. anyway, the easiest way would still be the .htaccess file. check google.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.