Forum Moderators: coopster
I wonder if there is really no possibility to use the
restrictive clause "if... else" when using the SELECT FROM
to login already registred members.
Does anybody knows what I mean?
Hereafter the php-page:
@mysql_connect($dbhost,$dbuser,$dbpass) or die("La Connexion a échouée"); @mysql_select_db($dbbase) or die("La Base $dbbase n'existe pas");
$result = mysql_query("SELECT id, login, mdp FROM DB WHERE login='".$_GET["login"]."' AND mdp='".$_GET["mdp"]."'")
or die ("error! this is not your login");
if(mysql_num_rows($result)>0)
{
list() = mysql_fetch_row($result);
?>
... follows the html party ...
</body>
</html>
<?php
}
else
echo "error, why don't you write in?";
?>
The page is displayed as if nothing were wrong! But, of course, should only when the user has correctly logged in.
Can anyone maybe help?
Would be great, thanks in advace,
mcLethe
$query = "SELECT * FROM administrators";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_assoc($result)) {
if($row["user_name"] == $_POST['username'] && $row["pass_word"] == $_POST['password']){
$_SESSION['admin'] = true;
header("location:index.php");
}
}
if(isset($_SESSION['admin']) == false){
header("location:login.php");
}
this does pretty much the same as what yours does except that it redirects to a page that handles failed logins, instead of just echoing to the page. It also stores a session variable as to whether the user is an administrator.
There a a couple of other things you should do like set all your comparison strings to upper case when comparing and also to validate for sql injections etc..
It works perfectly adding the session variable,
which gives something extremely simple and interesting if you are not fond of to storing 100'000'000 sessions in your DB!
Another question: Have you some experience in PHP/AS?
I am looking for someone who could really explain me
the basic client-side script of a AS-form as I have the
impression, slowly, that I make a basic mistake.
Would be great if I could get some help, seriously..
Thanks a lot,
mcLethe
[edited by: Scally_Ally at 8:09 am (utc) on July 20, 2006]