Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cannot parse-Simple error I'm sure! 2

Status
Not open for further replies.

tnsbuff

Technical User
Joined
Jan 23, 2002
Messages
216
Location
US
I'm a novice and trying to create a very simple password script, but getting a parse error on line 21 and can't see what the problem is. Can anyone here see the problem?

<html>
<head>
</head>
<body>

<?
$login_form = &quot;<form name='login' action='$PHP_SELF' method='post'>
<input name='op' type='hidden' value='ds'>
User Name: <input name='user'><br>
Password: <input type='password' name='pwd'><br><br>
<input type='submit'></form>&quot;;

if ($op != &quot;ds&quot;){
echo &quot;$login_form&quot;;
}
else {
if ($user==&quot;jones&quot; && $pwd == &quot;jones&quot;){
header(&quot;Location: }
}
else{
echo &quot;Login Information is Not Correct - Please Login Again&quot;;
echo &quot;$login_form&quot;;
}
?>
</body>
</html>

Thanks a bunch for any hints, subtle or otherwise. :-)
 
No, because you didn't enclose the code in the proper tags (click the Process TGML link at the bottom of the page for how to do this) so the code isn't here in it's unadulterated form. And also not sure because I don't know for certain where line 21 is not knowing if you have any whitespace or not.

Having said that I do notice that you appear to have an
Code:
if () {

} 
else {

}
else {

}

structure, which is not legal. I think you want... which would be fixed by moving one of those } after your header line to after your login_form line.

g'luck, and re-post using the code tags and some hints on which line is 21 if you'd like more help.

-Rob
 
tnsbuff:
The kind of error you have hit can be easily avoided through the use of source code indentation. If I format you code as:

Code:
if ($op != &quot;ds&quot;)
{
	echo &quot;$login_form&quot;;
}
else
{
	if ($user==&quot;jones&quot; && $pwd == &quot;jones&quot;)
	{
		header(&quot;Location: [URL unfurl="true"]http://url_here&quot;;);[/URL]
	}
}

else{
echo &quot;Login Information is Not Correct - Please Login Again&quot;;
echo &quot;$login_form&quot;;
}

I becomes easy to see that the last else clause does not belong to any if-statement.

Want the best answers? Ask the best questions: TANSTAAFL!
 
Sorry for forgetting about unchecking the TGML box.

You were right, the } needed to be at the end.

Also, I realized that the header needed to be up before the html tag, so I moved everything up to the top of the page and everything works fine now.

Thanks sleipnir214 for the tip about indenting.

... a star to each of you.

Thanks again.
 
Actually skiflyer, now that I look again, I think that is the actual code that I posted.

Line 21 was the line with:

else{
echo &quot;Login Information is Not Correct - Please Login Again&quot;;
echo &quot;$login_form&quot;;

Thanks again,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top