Litle problem with do statement !

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
Skywalker
Forum Contributor
Posts: 117
Joined: Thu Aug 29, 2002 3:33 am
Location: The Netherlands

Litle problem with do statement !

Post 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
Coco
Forum Contributor
Posts: 339
Joined: Sat Sep 07, 2002 5:28 am
Location: Leeds, UK
Contact:

Post 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
User avatar
Skywalker
Forum Contributor
Posts: 117
Joined: Thu Aug 29, 2002 3:33 am
Location: The Netherlands

Post 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");

?>
Coco
Forum Contributor
Posts: 339
Joined: Sat Sep 07, 2002 5:28 am
Location: Leeds, UK
Contact:

Post 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

&lt;?php
$Password = $_POST&#1111;'Password']; 
$Username = $_POST&#1111;'Username']; 

If(($Password == $row_recordset1&#1111;'Password']) &amp;&amp; ($Username == $row_recordset1&#1111;'Username'])) { 
echo ("Login gegevens zijn corect &lt;META HTTP-EQUIV="refresh" content="4;URL=product-list.php"&gt;\n"); 
} else { 
echo ("Login gegevens zijn niet corect &lt;META HTTP-EQUIV="refresh" content="5;URL=login.php"&gt;\n"); 
?&gt;
or

Code: Select all

&lt;?php
$Password = $_POST&#1111;'Password']; 
$Username = $_POST&#1111;'Username']; 

$login = (($Password == $row_recordset1&#1111;'Password']) &amp;&amp; ($Username == $row_recordset1&#1111;'Username'])); 

If($Login) { 
echo ("Login gegevens zijn corect &lt;META HTTP-EQUIV="refresh" content="4;URL=product-list.php"&gt;\n"); 
} else { 
echo ("Login gegevens zijn niet corect &lt;META HTTP-EQUIV="refresh" content="5;URL=login.php"&gt;\n"); 
?&gt;
;) hope this helps
Last edited by Coco on Mon Sep 09, 2002 3:30 am, edited 1 time in total.
User avatar
Skywalker
Forum Contributor
Posts: 117
Joined: Thu Aug 29, 2002 3:33 am
Location: The Netherlands

Post 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?
Coco
Forum Contributor
Posts: 339
Joined: Sat Sep 07, 2002 5:28 am
Location: Leeds, UK
Contact:

Post by Coco »

sorry i went back and edited cos i realised what i put werent enough :oops:
Coco
Forum Contributor
Posts: 339
Joined: Sat Sep 07, 2002 5:28 am
Location: Leeds, UK
Contact:

Post by Coco »

*frowns*
also you need to edit '&' to be '&' if you cut'n'paste that directly
User avatar
Skywalker
Forum Contributor
Posts: 117
Joined: Thu Aug 29, 2002 3:33 am
Location: The Netherlands

Post by Skywalker »

Ow ok thenk you :D
Coco
Forum Contributor
Posts: 339
Joined: Sat Sep 07, 2002 5:28 am
Location: Leeds, UK
Contact:

Post 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
:(
User avatar
Skywalker
Forum Contributor
Posts: 117
Joined: Thu Aug 29, 2002 3:33 am
Location: The Netherlands

Post by Skywalker »

Hmm that's a pitty, it still gives that same error? And the row is still empty? But thx enyway :D
lazy
Forum Newbie
Posts: 1
Joined: Mon Sep 09, 2002 5:21 am

Post by lazy »

im not sure.... but why you dont try this:

Code: Select all

&lt;?php 
$Password = $_POST&#1111;'Password'];  
$Username = $_POST&#1111;'Username'];  
If($Password == $row_recordset1&#1111;'Password'] &amp;&amp;$Username == $row_recordset1&#1111;'Username']) {  
echo ("Login gegevens zijn corect &lt;META HTTP-EQUIV="refresh" content="4;URL=product-list.php"&gt;\n");  
} else {  
echo ("Login gegevens zijn niet corect &lt;META HTTP-EQUIV="refresh" content="5;URL=login.php"&gt;\n"); 
}
?&gt;
User avatar
Skywalker
Forum Contributor
Posts: 117
Joined: Thu Aug 29, 2002 3:33 am
Location: The Netherlands

Post 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);
?>
User avatar
Takuma
Forum Regular
Posts: 931
Joined: Sun Aug 04, 2002 10:24 am
Location: UK
Contact:

Post 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! :wink:

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" :wink:
User avatar
Takuma
Forum Regular
Posts: 931
Joined: Sun Aug 04, 2002 10:24 am
Location: UK
Contact:

Post 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" :wink:
What am I saying? That's wrong by the way... :oops:
Coco
Forum Contributor
Posts: 339
Joined: Sat Sep 07, 2002 5:28 am
Location: Leeds, UK
Contact:

Post 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? :x
Post Reply