Help

Discussion in 'HTML & Website Design' started by liamizdabest, Jul 8, 2008.

  1. #1
    Hi,
    i want a script that asks for a password (just say it is "Password1") and if you get it wrong it says "invalid password, please try again" and if you get it right it says "Thank you!"

    Thanks very much! Any help for this simple script will be greatly appreciated.
     
    liamizdabest, Jul 8, 2008 IP
  2. k-aos

    k-aos Peon

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    <?PHP
    $password = $_POST['password'];
    
    if(isset($password)) {
        if ($password = "Password1") echo "Thank You!";
        else echo "Invalid password, please try again.";
    } else {
        echo "<FORM ACTION=\".\" METHOD=\"POST\">
              <label for=\"password\">Password:</label>
              <input type=\"password\" name=\"password\" />
              </FORM>";
    }
    ?>
    PHP:
    I'm not quite sure if this works :)P),
    so, pray, tell me if it does.
     
    k-aos, Jul 8, 2008 IP
  3. liamizdabest

    liamizdabest Guest

    Messages:
    387
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #3
    It says:

    Parse error: syntax error, unexpected '&' in /home/undergs3/public_html/activatepassword/index.php on line 5
     
    liamizdabest, Jul 8, 2008 IP
  4. Altari

    Altari Peon

    Messages:
    188
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #4
    The "unexpected &" is from a something else in the file.

    <?php
    $password = "foo";
    
    if(isset($_POST['submit'])) {
        if ($_POST['password'] == $password) {
              echo ("Thank You!");
        } else {
             echo ("Invalid password, please try again.");
        }
    } else {
    ?>
       <form method="POST">
       <p><label>Password</label><input type='password' name='password' /></p>
       <p><input type='submit' name='submit' value='go' /></p>
       </form>
    <?php
    }
    ?>
    Code (markup):
     
    Altari, Jul 8, 2008 IP