> Hi again.
>
> My code simply asks for a username and password but even if they insert
> incorrect details the called page is displayed.
>
> How can I get them to be redirected to another page if their login
> information is incorrect...?
>
>   echo "<p><h2>registerd users login here please...</p></h2>";
>   echo "<form action = 'members/index.php' method='POST'>";
>   echo "<pre>UserID:\t\t<input type = 'text' name = 'TXT_UserID'></pre>";
>   echo "<br><br>";
>   echo "<pre>Password:\t\t<input type = 'password' name =
> 'TXT_UserPassword'></pre>";
>   echo "<br>";
>   echo "<pre>\t\t<input type='submit' value='Submit Details'</pre>";
>   echo "</form>";
>
> -----------------------------
>  Michael Mason

What I usually do is set the form action to the same page as the above
code is applied to. Then I add an if statement at the top that checks the
login and redirects you to another page if login is successful. I think
you might want to give a name to your submit button as well, something
easy like name='submit'.

Then something like this at the top of the page:

if (isset($_POST["submit"])) {
  ...get user's password from database...
  if ($_POST["password"] == $db["password"]) {
     header("Location:members/index.php");
     exit;
  }
}

So if the login fails, they'll still be sitting at the login page. The
above code needs to be set before any HTML code, else the redirect won't
work.

http://us4.php.net/manual/en/function.header.php

--Matthew Sims
--<http://killermookie.org>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to