473,326 Members | 2,126 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

If working upside down

Here's your chance to clobber a newbie good! That's OK, I can take it
as long as it's relevant<g>.

In the following code snippet:
--------------------------------
<?php
if(empty($_POST["pw"])) echo "pw is EMPTY<br><br/>"; // set error to 1
else
echo "pw is not empty<br/>";

echo "pw is " . ($_POST["pw"]) . "<br/>";

if(($_POST["n"])==($_POST["pw"])) echo "correct pw entered<br/>"; //set
error to 0
else
echo "Wrong password entered";

?>
--------------------------------
I see the curly braces aren't there; they were earlier, but made no
difference.
The first "if" statement works fine and as expected: IF a pw is
entered, it indicates it's not empty and displays it correctly in the
next line.

However, the second "if" statement is upside down. If the pw is empty,
it says the correct pw was entered. If ANYTHING has been typed into the
"pw" field, it says the pw is wrong, including when the correct pw is
filled in!
It's more an "if empty" statement than it is a comparison of the two
variables.

The relevant part of the file providing the data is:
-------------------------------
<form method="post" action="nuCheckEntry.php">
<hr><br>
<?php
$n=rand(0,9) . rand(0,99) * 2;
echo $n . "<br>";
?>
<br>
<input type="text" name="pw">

<input type="submit" value="CONTINUE"

-------------------------

Screen output, with a correctly entered pw is:
pw is not empty
pw is 796 <=============== This IS what I entered for the pw.
Wrong password entered <====== but the correct pw was entered. However,
ANY
entry draws this
same output.
--------------------------

As you can see, I've sprinkled echoes around so I can see a little of
what's happening.

I realize I've probably got my head up my ... so don't worry about being
painfully honest; that's what I'm here for as long as it's on topic.
This isn't a "real" project, it's just sandbox time to see if I know
what I think I know; which I'm not too sure of at the moment. I seem to
be a lot better at fixing someone else's code (tut examples) than I am
at writing my own!! <G>

Specifically: What's wrong with that 2nd "if" statement that makes it
seem to be working so wrongly? Or is the problem elsewhere?

TIA,

Twayne
Jun 27 '08 #1
2 1518
Twayne wrote:
-------------------------------
<form method="post" action="nuCheckEntry.php">
<hr><br>
<?php
$n=rand(0,9) . rand(0,99) * 2;
echo $n . "<br>";
?>
<br>
<input type="text" name="pw">

<input type="submit" value="CONTINUE"
You're not posting the value of 'n' in the form.
Cheers,
--
----------------------------------
Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-

You though your secrets were safe.
You were wrong.
-- From "Hackers" movie poster.
Jun 27 '08 #2
Twayne wrote:
>
>-------------------------------
<form method="post" action="nuCheckEntry.php">
<hr><br>
<?php
$n=rand(0,9) . rand(0,99) * 2;
echo $n . "<br>";
>>>
<br>
<input type="text" name="pw">

<input type="submit" value="CONTINUE"

You're not posting the value of 'n' in the form.
Cheers,
GAKK!!! I knew it'd be something stupid like that! Time for a long
coffee break I think.
Thanks, I've been staring at that off & on since yesterday afternoon.

Twayne
Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Cc | last post by:
how do I draw string upside down?
36
by: AussieRules | last post by:
Hi, I want to use the user color scheme to set the color of my forms. I now I have to use the. System.Drawing.SystemColors, but which color is the color of a form background as used in other...
7
by: MrCode2k | last post by:
Hello, Trying to do: I just want a table that I can scroll and that has fixed headers. Problem: I got it to work but when I added the onmouseover event it didn't work anymore....
14
by: stevek | last post by:
Following code does not produce any new lines. Any ideas. echo "This spans\multiple lines. The newlines will be\noutput as well.";
0
by: Kwok | last post by:
Using html, I want to rotate the word upside down. When a user input a sentence, the sentence then will rotate 180degree. I use <div>, it can only rotate 90degree..... can anyone help me??
1
by: llloyd wood | last post by:
/** * @(#)MyClock.java * * MyClock application * * @author kevin * @version 1.00 2007/4/4 */ import java.awt.*; import java.awt.event.*;
2
by: =?Utf-8?B?bm9vcmphYmFs?= | last post by:
My cat lay along the lower end of my keyboard while the computer was on - which turned the contents of the screen upside down! Re-booting and shutting down have failed to solve the problem. I...
5
by: Gina_Marano | last post by:
Hey All, Is it possible to draw an image upside down? I am using Microsofts example of "Printing a local report without preview". The only trick is that I want to flip the image upside...
12
Banfa
by: Banfa | last post by:
Nice article but what does LSP actually stand for?
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.