|
Posted by quik_silv on 10/12/06 13:38
You can try this code, of course you need to get the $_POST['userid']
and $_POST['password'] which are input by the user.
//to connect to your database
include 'dbconnect.php';
//store session variables
session_start();
$_SESSION['userid']=$_POST['userid'];
$_SESSION['password']=$_POST['password'];
$userid=$_POST['userid'];
$password=$_POST['password'];
//here I check the password that the user entered with the one in the
database
$user = mysql_query("SELECT * FROM users WHERE userid = '$userid'")or
die(mysql_error());
//load the mySQL query as an array in $info, where you could refer to
the password using //$info["password"]
while($info = mysql_fetch_array($user) ) {
if ($password != $info["password"]) {
die('Wrong userid or password!');
session_destroy();
}
else {
echo "Welcome ".$_SESSION['userid'].". You have unlocked the key.";
exit;
}
}
Regards,
Mark Wong
http://liang5ster.blogspot.com
Garry Jones wrote:
> "Moot" <mootmail-googlegroups@yahoo.com> skrev i meddelandet
> news:1160598589.611992.313100@k70g2000cwa.googlegroups.com...
>
> > If the check fails (ex: if the password is wrong, or they navigate
> > directly to the page), then use header("location: whatever"); to
> > redirect them immediately to some other page.
>
> Yes I got that bit. But if the user goes straight to the page he jumps in
> and the password entered and the password processed are identical null
> values.
>
> What I mean is in this example
>
> $_POST['user_try'] will be empty if the user has typed in the page name of
> the processing page directly. I am unsure how empty because the checking for
> ($_POST['user_try'] == "") was not enought to trap it, it appears there is
> some kind of null that is not recognised as being "". However when I echoed
> it to check there was nothing there.
>
> I have been playing with isset but cant cant get the syntax.
>
> if (isset($_POST['user_try'])){
> lots of code goes here to kick off the page
> after which then i can close the if statement
> }
> Header("Location: whatever.php");
> exit;
>
>
> ... But I am still missing something, greatfull for any help
> Garry Jones
> Sweden
Navigation:
[Reply to this message]
|