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
Random
Forum Commoner
Posts: 30 Joined: Wed Mar 12, 2003 5:38 pm
Post
by Random » Thu Mar 13, 2003 6:09 pm
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ї'username'];
$pass = "none";
$cool = array( "Shurik'n", "Random", "Thug_Wigga", "Tracer" );
global $pass;
if ($_POSTї'username'] == "$name" && $_POSTї'password'] == "$pass") {
print "Welcome $name, please have a look around..at the nice white blank site.";
print "<br>";
}
elseif ( $_POSTї'password'] == "" ) {
print "Please enter a god darned password...retard.";
}
elseif ( $_POSTї'username'] == $name && $_POSTї'password'] != $pass ) {
print "Sorry bud, your password is incorrect."
}
else ($name != $cool ) {
global $cool;
print "Go away unless you are $coolї0], $coolї1], $coolї2], or $coolї3]";
}
?>
</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ї'username'] == $name && $_POSTї'password'] != $pass ) {
print "Sorry bud, your password is incorrect."
}
Thanks in advance
volka
DevNet Evangelist
Posts: 8391 Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger
Post
by volka » Thu Mar 13, 2003 6:34 pm
PHP Parse error: parse error, unexpected '{' in test.php on line 24
you forgot a "if" or a comment
or
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 » Thu Mar 13, 2003 7:37 pm
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?
twigletmac
Her Royal Site Adminness
Posts: 5371 Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK
Post
by twigletmac » Fri Mar 14, 2003 2:17 am
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
twigletmac
Her Royal Site Adminness
Posts: 5371 Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK
Post
by twigletmac » Fri Mar 14, 2003 2:23 am
You forgot a semi-colon at the end of this line:
Code: Select all
print "Sorry bud, your password is incorrect."
Mac
volka
DevNet Evangelist
Posts: 8391 Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger
Post
by volka » Fri Mar 14, 2003 4:59 am
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...
twigletmac
Her Royal Site Adminness
Posts: 5371 Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK
Post
by twigletmac » Fri Mar 14, 2003 5:01 am
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 » Fri Mar 14, 2003 2:27 pm
ah it isnt a big thing, I was just messing around, day 3 of learning php
just testing how to login with forms, etc.
just read the
$_SESSION_start(); stuff...hopefully that works for me. Thanks for the info guys.
volka
DevNet Evangelist
Posts: 8391 Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger
Post
by volka » Fri Mar 14, 2003 3:44 pm
...and gals