SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2002
    Posts
    26
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Simple Password Script - Help!

    Hello to all. I have a simple password script that doesn't run. Please take a look and give any suggestions/feedback.
    Thanks
    PHP Code:
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>

    <body>
    <?
      
    if(!isset($name)&&!isset($password))
      {
        
    //Visitor needs to enter a name and a password
    ?>

    <h1>Please Log In</h1>
    This page is secret.
    <form method = post action = "secret.php">
    <table border = 1>
    <tr>
      <th> Username </th>
      <td> <input type = text name = name> </td>
    </tr>
    <tr>
      <th> Password </th>
      <td> <input type = password name = password> </td>
    </tr>
    <tr>
      <td colspan =2 align = center>
      <input type = submit value = "Log In">
    </td>
    </tr>
    </table>
    </form>

    <?
      
    }
      else if(
    $name=="user"&&$password=="pass")
      {
        
    //visitor's name and password combination are correct
        
    echo "<h1>Here it is!</h1>";
        echo 
    "I bet you are happy you can see this secret page.";
      }
      else
      {
        
    //visitor's name and password combination are not correct
        
    echo "<h1>GO AWAY!</h1>";
        echo 
    "You are not authorized to view this resource.";
      }
    ?>

    </body>
    </html>

  2. #2
    SitePoint Addict Mo Money's Avatar
    Join Date
    Nov 2002
    Posts
    274
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This should work, although its sloppy:
    PHP Code:
    <?php

    if(!isset($name)&&!isset($password)) {

    echo = 
    '<h1>Please Log In</h1>

    This page is secret.

    <form method="post" action = "secret.php">

    <table border = 1>

    <tr>

    <th> Username </th>

    <td> <input type = text name = name> </td>

    </tr>

    <tr>

    <th> Password </th>

    <td> <input type = password name = password> </td>

    </tr>

    <tr>

    <td colspan =2 align = center>

    <input type = submit value = "Log In">

    </td>

    </tr>

    </table>

    </form>'
    ;

    }

    elseif((
    $name == "user") && ($password == "pass")) {

    ____//visitor's name and password combination are correct

    ____echo_"<h1>Here it is!</h1>";

    ____echo_"I bet you are happy you can see this secret page.";

    }

    else

    {

    //visitor's name and password combination are not correct

    echo_"<h1>GO AWAY!</h1>";

    echo_"You are not authorized to view this resource.";

    }

    ?>
    AbcArcade.com - free internet games!

  3. #3
    SitePoint Enthusiast
    Join Date
    Dec 2002
    Location
    Best City 2002 - Melbourne, Australia
    Posts
    83
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    chagne $name and $password to $_POST['name'] and $_POST['password'] respectively
    Don't push me.

  4. #4
    SitePoint Enthusiast
    Join Date
    Nov 2002
    Posts
    26
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry gys. Still no go. Parse errors and the like. Any suggestions??

  5. #5
    SitePoint Zealot
    Join Date
    Oct 2001
    Location
    London, UK.
    Posts
    103
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    My suggestion is for you to post the "new" code you are using and the exact lines that errors appear on.
    We can't do much without knowing what errors your getting!

    David
    Do you fear the obselescence of the
    metanarrative apparatus of legitimation?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •