Page 1 of 1

Problem that I can't see...

Posted: Thu Mar 13, 2003 6:09 pm
by Random
Hello, I am making a simple form/login type thing and I have a line that i just added but it makes none of my other chunks of scripts work. Here it is in full:

Code: Select all

<HTML>
<HEAD>
<TITLE>.: Processing :.</TITLE>
</HEAD>
<BODY>
<?php
$name = $_POST&#1111;'username'];
$pass = "none";
$cool = array( "Shurik'n", "Random", "Thug_Wigga", "Tracer" );
global $pass;
if ($_POST&#1111;'username'] == "$name" && $_POST&#1111;'password'] == "$pass") &#123;
	print "Welcome $name, please have a look around..at the nice white blank site.";
	print "<br>";
&#125;

elseif ( $_POST&#1111;'password'] == "" ) &#123;
	print "Please enter a god darned password...retard.";
&#125;
	
elseif ( $_POST&#1111;'username'] == $name && $_POST&#1111;'password'] != $pass ) &#123;
	print "Sorry bud, your password is incorrect."
&#125;

else ($name != $cool ) &#123;
	global $cool;
	print "Go away unless you are $cool&#1111;0], $cool&#1111;1], $cool&#1111;2], or $cool&#1111;3]";
&#125;

?>
</BODY>
</HTML>
The line that I added is this, and after I had added it, the script didnt work right.

Code: Select all

elseif ( $_POST&#1111;'username'] == $name && $_POST&#1111;'password'] != $pass ) &#123;
	print "Sorry bud, your password is incorrect."
&#125;
Thanks in advance

Posted: Thu Mar 13, 2003 6:34 pm
by volka
PHP Parse error: parse error, unexpected '{' in test.php on line 24
you forgot a "if" or a comment

Code: Select all

else if($name != $cool ) {
or

Code: Select all

else //($name != $cool )
{
Please try to explain what this script is doing, then you will find that there are some mistakes in it (at least I believe so ;) )

Posted: Thu Mar 13, 2003 7:37 pm
by Random
that line isnt giving me the trouble, i already said that. The line that is giving me trouble is the one that says "if the password isnt correct, then print out 'Sorry bud, your password is incorrect'". Thanks anways, someone help pls?

Posted: Fri Mar 14, 2003 2:17 am
by twigletmac
Random wrote:the script didnt work right
Error messages or what happens/doesn't happen that shouldn't/should?

Difficult to help without that information.

Mac

Posted: Fri Mar 14, 2003 2:23 am
by twigletmac
You forgot a semi-colon at the end of this line:

Code: Select all

print "Sorry bud, your password is incorrect."
Mac

Posted: Fri Mar 14, 2003 4:59 am
by volka
ah, right. I fixed that error before testing the script with php -l and forgot it ;)
Nevertheless I believe there are some errors in the script, e.g.

Code: Select all

$name = $_POST['username'];
...
if ($_POST['username'] == "$name"
unless php is broken there is no doubt that this is always true...

Posted: Fri Mar 14, 2003 5:01 am
by twigletmac
:lol: I didn't see that - does make the test a bit pointless. There are definitely a few things that would make this script not work as expected.

Mac

Posted: Fri Mar 14, 2003 2:27 pm
by Random
ah it isnt a big thing, I was just messing around, day 3 of learning php :D just testing how to login with forms, etc.

just read the
$_SESSION_start(); stuff...hopefully that works for me. Thanks for the info guys.

Posted: Fri Mar 14, 2003 3:44 pm
by volka
...and gals :wink: