linking

They have: 314 posts

Joined: Nov 1999

Hey,

This might have been asked beofre but anyway....

How do you link to a certain part of a script. IE, you login through the password protection and end up in the admin area and then you have linkto various areas of the script like "create page" etc.

This is just one file so how do you link to the various functions.

Thanks alot

They have: 193 posts

Joined: Feb 2000

Simply put the functions in seperate sub routines. The format for a sub routine looks like this:

sub NAME_OF_SUB {

#code here

}
'

To call a subroutine:

&NAME_OF_SUB;
'

Just replace "NAME_OF_SUB" with the actual name of the subroutine. Smiling

Richard

[email protected]

Everyone here has a website. It's just that not all are worth posting (Mine! Smiling).

They have: 314 posts

Joined: Nov 1999

No, you misunderstand....

I meant like NAME

I want the script be one script but I want the admin area to link to different parts of the script. os can I do:

something

or doews it have to me in multiple scripts and not one single one

They have: 193 posts

Joined: Feb 2000

This is possible.

Let's say you had three sections: admin, form, and default. To call a seperate section, use a URL like this:

script.cgi?section=admin

#!/usr/bin/perl

BEGIN {
use CGI::Carp qw(fatalsToBrowser);
}

use CGI qw(param header);
print header;

$section = param('section');

if ($section eq "admin") { &admin; }
elsif ($section eq "form") { &form; }
else { &default; }
exit;

sub admin {
print qq|This is the admin section|;
}

sub form {
print qq|This is the form section|;
}

sub default {
print qq|This is the default section|;
}
'

Hope that solved your question. Smiling

Richard

[email protected]

Everyone here has a website. It's just that not all are worth posting (Mine! Smiling).

They have: 314 posts

Joined: Nov 1999

I'll try it later on today but it looks good. Thanks alot for your help Smiling

They have: 314 posts

Joined: Nov 1999

but am having a problem with it.

I am using a primitive password control system which will disply the admin side of the script iff the password is corrct and a bad passowrd page if it is not.

My problem is this:

When I accessed my script I had forgotten to take put the else {&default} bit so it showed that message instead ofmy login. I took this out (so there is no else) but nothing showed up. So I cahnged the &default for &ask_password (the main login screen). this worked. But when i presss ubmit it juist loads the login page again. I dont know why this is (actually I do but I dont know how to fix it). I am assuming it is doing this becase the function is not specified in the code richard gave me. Anyway, this is the code tghat checks the passoword:

&parse_form;

$password = $input{'password'};
$function = $input{'function'};

if ($function eq "post") {
if ($password eq $correctpass) {
&goodlogin;
}
&nologin;
}

&ask_password;

and this is at the top:

$section = param('section');

if ($section eq "admin") { &admin; }
elsif ($section eq "footer") { &footer; }
elsif ($section eq "header") { &header; }
elsif ($section eq "subscribers") { &subscribers; }
elsif ($section eq "archive") { &archive; }
elsif ($section eq "sendmail") { &sendmail; }
elsif ($section eq "sendonemail") { &sendonemail; }
else {&ask_password}
exit;

Can someopne help me???

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.