Page 1 of 2
Litle problem with do statement !
Posted: Mon Sep 09, 2002 2:11 am
by Skywalker
Hey how can you make a do statement when something is even or the samen. for example, to be more clear.
if $Name = $Username & $Password = Pass {
then do (GO TO URL)
} else {
echo ("Enter wrong password/username");
}
THX
Posted: Mon Sep 09, 2002 2:52 am
by Coco
try this...
Code: Select all
<?php
if ($Name = $Username && $Password = $Pass) {
//CODE
} else {
echo ("Enter wrong password/username");
}
?>
Try also to make your variable names more meaningful or else your gonna be scratching your head as to what is what
Posted: Mon Sep 09, 2002 3:10 am
by Skywalker
I have now this, the recodset are from out of the database what the users are posting has to match with on of the record in the table. If not then erro login or what ever.
<?php
$Password = $_POST['Password'];
$Username = $_POST['Username'];
If($Login) {
$Password = $row_recordset1['Password'] & $Username = $row_recordset1['Username'];
echo ("Login gegevens zijn corect <META HTTP-EQUIV=\"refresh\" content=\"4;URL=product-list.php\">\n");
} else {
echo ("Login gegevens zijn niet corect <META HTTP-EQUIV=\"refresh\" content=\"5;URL=login.php\">\n");
?>
Posted: Mon Sep 09, 2002 3:19 am
by Coco
you need && for your and statement not &, and = should be ==...
your logic statement is in the wrong place too....
it doesnt do anything much where it is... it should be either an argument for your if or it should be outside it....
ie...
Code: Select all
<?php
$Password = $_POSTї'Password'];
$Username = $_POSTї'Username'];
If(($Password == $row_recordset1ї'Password']) && ($Username == $row_recordset1ї'Username'])) {
echo ("Login gegevens zijn corect <META HTTP-EQUIV="refresh" content="4;URL=product-list.php">\n");
} else {
echo ("Login gegevens zijn niet corect <META HTTP-EQUIV="refresh" content="5;URL=login.php">\n");
?>
or
Code: Select all
<?php
$Password = $_POSTї'Password'];
$Username = $_POSTї'Username'];
$login = (($Password == $row_recordset1ї'Password']) && ($Username == $row_recordset1ї'Username']));
If($Login) {
echo ("Login gegevens zijn corect <META HTTP-EQUIV="refresh" content="4;URL=product-list.php">\n");
} else {
echo ("Login gegevens zijn niet corect <META HTTP-EQUIV="refresh" content="5;URL=login.php">\n");
?>

hope this helps
Posted: Mon Sep 09, 2002 3:24 am
by Skywalker
The page gives me an error, this error
Parse error: parse error, unexpected $ in c:\inetpub\wwwroot\test\TMP3p6yr25wt8.php on line 36
But on that line ther is nothing written? It is empty?
Posted: Mon Sep 09, 2002 3:31 am
by Coco
sorry i went back and edited cos i realised what i put werent enough

Posted: Mon Sep 09, 2002 3:32 am
by Coco
*frowns*
also you need to edit '&' to be '&' if you cut'n'paste that directly
Posted: Mon Sep 09, 2002 3:35 am
by Skywalker
Ow ok thenk you

Posted: Mon Sep 09, 2002 3:37 am
by Coco
chances are if you fix the if statement that will resolve itself...
if it doesnt im too much a newbie to help you further with that

Posted: Mon Sep 09, 2002 3:40 am
by Skywalker
Hmm that's a pitty, it still gives that same error? And the row is still empty? But thx enyway

Posted: Mon Sep 09, 2002 5:21 am
by lazy
im not sure.... but why you dont try this:
Code: Select all
<?php
$Password = $_POSTї'Password'];
$Username = $_POSTї'Username'];
If($Password == $row_recordset1ї'Password'] &&$Username == $row_recordset1ї'Username']) {
echo ("Login gegevens zijn corect <META HTTP-EQUIV="refresh" content="4;URL=product-list.php">\n");
} else {
echo ("Login gegevens zijn niet corect <META HTTP-EQUIV="refresh" content="5;URL=login.php">\n");
}
?>
Posted: Mon Sep 09, 2002 7:23 am
by Skywalker
The script isn't giving eny erro enymore, but it is still not good, because it is send al the time back login incorect but the username and password was fild in corect? What the hell is wrong with this script?
can somebody tel me please getting nuts over here.
<?php require_once('../Connections/Verbinding.php'); ?>
<?php
mysql_select_db($database_Verbinding, $Verbinding);
$query_Recordset1 = "SELECT * FROM user";
$Recordset1 = mysql_query($query_Recordset1, $Verbinding) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
$Password = $_POST['Password'];
$Username = $_POST['Username'];
If($Password == $row_recordset1['Password'] && $Username == $row_recordset1['Username']) {
echo ("Login gegevens zijn corect <META HTTP-EQUIV=\"refresh\" content=\"4;URL=product-list.php\">\n");
} else {
echo ("Login gegevens zijn niet corect <META HTTP-EQUIV=\"refresh\" content=\"5;URL=login.php\">\n");
}
?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>
Posted: Mon Sep 09, 2002 7:44 am
by Takuma
Skywalker wrote:The script isn't giving eny erro enymore, but it is still not good, because it is send al the time back login incorect but the username and password was fild in corect? What the hell is wrong with this script?
can somebody tel me please getting nuts over here.
?? Type it correct!
By the way there is a major security issue here, if you don't type in your password and username it will say "Login Success"

Posted: Mon Sep 09, 2002 7:47 am
by Takuma
Takuma wrote:By the way there is a major security issue here, if you don't type in your password and username it will say "Login Success"

What am I saying? That's wrong by the way...

Posted: Mon Sep 09, 2002 8:09 am
by Coco
Php Manual wrote:Variables in PHP are represented by a dollar sign followed by the name of the variable. The variable name is case-sensitive.
Skywalker wrote:
<?php
mysql_select_db($database_Verbinding, $Verbinding);
$query_Recordset1 = "SELECT * FROM user";
$Recordset1 = mysql_query($query_Recordset1, $Verbinding) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
$Password = $_POST['Password'];
$Username = $_POST['Username'];
If($Password == $row_recordset1['Password'] && $Username == $row_recordset1['Username']) {
echo ("Login gegevens zijn corect <META HTTP-EQUIV="refresh" content="4;URL=product-list.php">\n");
} else {
echo ("Login gegevens zijn niet corect <META HTTP-EQUIV="refresh" content="5;URL=login.php">\n");
}
?>
get the impression im used to staring at code looking for bad syntax?
