More incredibly simple problems

They have: 314 posts

Joined: Nov 1999

Hey people. I have a new problem! woohoo!

I am using perl for win 98 to test my scripts and debug then etc. Ironing our errors offline before putting them up there and seeing "Internal server error 500" which I have come to expect whenever I make a script.

I am getting a syntax error "on line 66 near print". The code:

sub mainlogin {
print "Content-type: text/html\n\n";
print "<HTML><HEAD>\n";
print "<TITLE>$adminname</TITLE></HEAD>\n";
print "<BODY><CENTER><p><font color="#FF0000" size="4" face="Comic Sans MS">You are attempting to enter an area of $name which is only for authorised employee's. If you are an admin then please enter your password. If not, please </font><a href="$url"><font size="4" face="Comic Sans MS">leave</font></a></p>\n";
print "<FORM ACTION=\"scripturl\">\n";
print "<INPUT TYPE=password NAME=password SIZE=15>\n";
print "<INPUT TYPE=hidden NAME=function VALUE=post>\n";
print "<INPUT TYPE=submit VALUE=\" Verify Me \">\n";
print "</FORM>\n";
print "</BODY></HTML>\n";

exit;
}

Line 66 is in bold. I got the script from a password script and am adapting it so that instead of redirecting to a webpage it will carry on running the script (go to the admin section etc). Because it is from another freebie script and I am very new to perl (only starting learning the other week) I am not able to figure out what is wrong. Any help would be great.

Also, is it possible in perl to link to a specific part of a script like sub mainlogin. If so is it possible to use a form action as a specific part of a script?

Thanks.

------------------
Thomas Minton
The JavaScript Place
Get paid $20 - $160 an hour for viewing adverts

Ken Elliott's picture

They have: 358 posts

Joined: Jun 1999

On The lines above line 66 you have not escaped your " double quotes. Just put a \slash before each double quote inside each print statement, and you should be fine.

I've yet to do this, but you can link to a specific part of your script by using if statements.

Put in one of your forms <input type="hidden" name="mode" value="mainlogin">
Then in your script put everything needed for mainlogin within a if statement something like this.

if ($mode eq "mainlogin") {
Mainlogin code goes here
} elsif ($mode eq "somethingelse") {
Other code goes here
} else {
print "NO MODE WAS SELECTED";
}

I think that would work
VulKen
I GOT BEEF

I think this would actually fix my problem too. Wow.
[This message has been edited by VulKen (edited 20 June 2000).]

[This message has been edited by VulKen (edited 20 June 2000).]

Pimpin like a pimp with an electrofied pimpin machine!

They have: 314 posts

Joined: Nov 1999

Thanks Vulken! I got the script working first time!

About the linking to a specific part. I wm going to be making a script with essentially two parts in it. The password to protect it (duh ) and the actual news script (the part which will take the contents of twio text boxes and print to a new page). Do I need the form action of the form with the text boxes in to link to a specific part of a script or will it automatically find the part in the script by it self?

Thanks for you help Vulken

------------------
Thomas Minton
The JavaScript Place
Get paid $20 - $160 an hour for viewing adverts

Ken Elliott's picture

They have: 358 posts

Joined: Jun 1999

Near the top of one of your script you may see a line somewhat similar to this:

$password = $formdata{'password'};

Just copy that line and paste in a copy like this.

$mode = $formdata{'mode');

Then in the script, use the script format that I posted in the first post to seperate the different parts of your script.

Then in the form that is to send your user to the specific area put in between the <form></form> tags:

<input type="hidden" name="mode" value="password">

That should do ya...

VulKen
NO MORE BOTTLES OF BEER ON THE WALL?

[This message has been edited by VulKen (edited 20 June 2000).]

Pimpin like a pimp with an electrofied pimpin machine!

They have: 314 posts

Joined: Nov 1999

<<<<<<<<SNIP>>>>>>>>>
I figured out what it was so no problems
>>>>>>>>SNIP<<<<<<<<<

[This message has been edited by minton (edited 23 June 2000).]

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.