Previous Thread
Next Thread
Print Thread
Rate Thread
#101827 12/21/2000 11:53 AM
Joined: Sep 2000
Posts: 138
Em8
Offline
Member
Member
Offline
Joined: Sep 2000
Posts: 138
It's supposed to be a link script but it only shows "Add a Link" and when I try to add one it tries to submit to "a=add&var=false" and not "var=true".
shareit.cgi:
Code
code:

links.cgi:
Code
code:

------------------

Sponsored Links
#101828 12/21/2000 1:26 PM
Joined: Oct 2000
Posts: 24
Member
Member
Offline
Joined: Oct 2000
Posts: 24
You're confusing the CGI perl module by declaring $var to be a 'form' value, and a URL value.

The structure is a little messy too, here's something to think about.

This is far, far from perfect:

#!/usr/bin/perl -wT


# Made by me for me but you may use it. If it crashes your sever I take no responsibility
# v1.0 by Em8
# Copyright(C) 2000


use CGI;
use strict;
use Fcntl qw([Linked Image]EFAULT :flock);

my $q = new CGI;

my $a = $q->param('a');
my $var = $q->url_param('var');

print $q->header();

if ($a) {

main() if $a eq 'main';
submitlink() if ($a eq 'add' and $var eq 'false');
make() if ($a eq 'add' and $var eq 'true');

} else {
main();
}


sub main {
open LINKS, ' flock LINKS, LOCK_SH or die $!;
while ( ) {
@_ = split /|!|/;
print qq(
$.: $_[1] $_[6]


>

$_[2]

$_[4]




);
}
close LINKS or die $!;

print "

Add A Link
";
}

sub submitlink {

print $q->startform (-uri=>'www.yourdomain.com?var=true',-method=>'post');
print<
Enter Your Name:

Enter Your Website URL:

Enter Your Website Name:

Comments about your wedsite:



ENTER
}

sub make {
# Print the file

my $T1 = $q->param(Maker);
my $T3 = $q->param(URL);
my $T2 = $q->param(Name);
my $T4 = $q->param(About);
my $T5 = $ENV{'REMOTE_ADDR'};
my $T6 = localtime();

open THIS, '>>links.cgi' or die $!;
print THIS "$T1|!|$T2|!|$T3|!|$T4|!|$T5|!|$T6n";
close THIS or die $!;
}

This message has been edited by Matt@ikonboard on December 21, 2000 at 12:31 PM

#101829 12/21/2000 1:39 PM
Joined: Sep 2000
Posts: 755
P.I.T.A. / Programmer
P.I.T.A. / Programmer
Offline
Joined: Sep 2000
Posts: 755
Your logic in sub main is incorrect. You're reading the contents of the file into @vlink, then changing vlink to be the contents of grepped lines from @links (which doesn't exist). So now @vlinks is empty.

You theh assign the vars like $Maker, $Name etc to the different elements of @vlink (which is empty, so all these vars are now empty) and once you've assigned each part of the @vlinks array, you then foreach through it? Plus when you do your variable assignment, you're starting at 1. First element in the array should be 0 [Linked Image]

You need to diagram your flow on paper, then code to follow what you're trying to do [Linked Image]

To give you a start, I *think* this is what you're looking for, for sub main:

Code
code:

--mark


"Annnnnnnndd now, opening for Iron Maiden...... WYLD STALLYNS!!!" --Bill S. Preston, Esquire and Ted "Theodore " Logan
#101830 12/21/2000 1:46 PM
Joined: Oct 2000
Posts: 24
Member
Member
Offline
Joined: Oct 2000
Posts: 24
Scratch all that, I've just figured what you're trying to do.

Code
code:

This message has been edited by Matt@ikonboard on December 21, 2000 at 12:57 PM

#101831 12/21/2000 3:11 PM
Joined: Sep 2000
Posts: 138
Em8
Offline
Member
Member
Offline
Joined: Sep 2000
Posts: 138
would this mean to replace "use strict;" with "use strict qw(vars);"?:
Code
code:

------------------

Sponsored Links
#101832 12/21/2000 3:22 PM
Joined: Sep 2000
Posts: 138
Em8
Offline
Member
Member
Offline
Joined: Sep 2000
Posts: 138
When I try that I get:
Quote
quote:
Line 25 is: print qq(
Line 18 is: $Mode{$act} ? $Mode{$act}->() : ShowLinks();

------------------

#101833 12/21/2000 4:30 PM
Joined: Oct 2000
Posts: 24
Member
Member
Offline
Joined: Oct 2000
Posts: 24
You'll need to single quote the 'param('word') stuff.

Don't worry about those spurious warn's - it's there to let you know of possible error's (syntax, and/or logical) - even the CGI perl module turns off warnings in places.

#101834 12/21/2000 9:28 PM
Joined: Sep 2000
Posts: 138
Em8
Offline
Member
Member
Offline
Joined: Sep 2000
Posts: 138
Got it:
http://opena.virtualave.net/cgi-bin/shareit.cgi?
Code
code:

------------------


This message has been edited by Em8 on December 21, 2000 at 08:35 PM


Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
Gizmo
Gizmo
Portland, OR, USA
Posts: 5,833
Joined: January 2000
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20221218)