Access page by a code // PHP //

Status
Not open for further replies.

TrueJewix

Member
Aug 9, 2012
332
21
Alright, so is it possible to make users access the home page by a code
Let me show you a sample :

(index page) Say our password is BETA. I want it so like whenever user enters the password "BETA" it allows them it directs them to home page, but if they enter a password such as TROLL, WOOP & more, it denies their access hopefully you understood me.

Thanks!
 

Cookiez38

Member
Aug 14, 2014
40
5
Hey,

you should try to learn php it's easy to do that, i think its the first thing you gonna learn if you start learning php ^^

here we go:
First put this code in your main page (index.php??)
HTML:
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title>Protected Page</title>
    </head>
    <body>
<center>
<form action="lock.php" method="post">
Password:<br><input type="password" name="psw" /><br>
<input type="submit" value="Let's GO !" />
</form>
</center>

    </body>
</html>

Then create a separated page and call it "lock.php" and put this code inside.
PHP:
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title>Unlocked Page</title>
    </head>
    <body>
   
        <?php
        $pass= "Beta"; // your password !
    if (isset($_POST['psw']) AND $_POST['psw'] ==  $pass) // IF the password is good
    {
    // We show our content
    ?>
        <h1>Here are the beta key :</h1>
        <p><strong>CRD5-GSFT-CK77-JODM-V42M-25G3-SH28-LIFV</strong></p>  
       
        <p>
        This page is only for Staff<br />
        </p>
        <?php
    }
    else // Else, we show an error message
    {
        echo '<p>Wrong password</p>';
    }
    ?>
   
    </body>
</html>

I commented my codes hope its help you.
 

TrueJewix

Member
Aug 9, 2012
332
21
Hey,

you should try to learn php it's easy to do that, i think its the first thing you gonna learn if you start learning php ^^

here we go:
First put this code in your main page (index.php??)
HTML:
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title>Protected Page</title>
    </head>
    <body>
<center>
<form action="lock.php" method="post">
Password:<br><input type="password" name="psw" /><br>
<input type="submit" value="Let's GO !" />
</form>
</center>

    </body>
</html>

Then create a separated page and call it "lock.php" and put this code inside.
PHP:
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title>Unlocked Page</title>
    </head>
    <body>
  
        <?php
        $pass= "Beta"; // your password !
    if (isset($_POST['psw']) AND $_POST['psw'] ==  $pass) // IF the password is good
    {
    // We show our content
    ?>
        <h1>Here are the beta key :</h1>
        <p><strong>CRD5-GSFT-CK77-JODM-V42M-25G3-SH28-LIFV</strong></p> 
      
        <p>
        This page is only for Staff<br />
        </p>
        <?php
    }
    else // Else, we show an error message
    {
        echo '<p>Wrong password</p>';
    }
    ?>
  
    </body>
</html>

I commented my codes hope its help you.

I found some other thing on google but i'm using this since you commented your codes so it doesn't confuse me in the future Thanks once again :p
 

Cookiez38

Member
Aug 14, 2014
40
5
One questions I want them to go to home.html how do I do that?
you are welcome.

To redirect them to home.html
first you need to rename home.html to home.php
and then copy all codes inside lock.php to home.php
then go to index.php (main page)
find this :
HTML:
<form action="lock.php" method="post">
Change it to :
HTML:
<form action="home.php" method="post">
 
Status
Not open for further replies.

Users who are viewing this thread

Top