Problem that I can't see...

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

Post Reply
Random
Forum Commoner
Posts: 30
Joined: Wed Mar 12, 2003 5:38 pm

Problem that I can't see...

Post 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
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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 ;) )
Random
Forum Commoner
Posts: 30
Joined: Wed Mar 12, 2003 5:38 pm

Post 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?
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

You forgot a semi-colon at the end of this line:

Code: Select all

print "Sorry bud, your password is incorrect."
Mac
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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...
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
Random
Forum Commoner
Posts: 30
Joined: Wed Mar 12, 2003 5:38 pm

Post 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.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

...and gals :wink:
Post Reply