Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 13th, 2001, 05:50 PM
writhe writhe is offline
Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2001
Location: Houston
Posts: 9 writhe User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
newbie with form problem

Hi all-

I'm a major newbie and I'm trying to get a simple form to work. I just wanna gather info and record it into a text file. Here's the script:

#!/usr/bin/perl -w

use strict;
use CGI qw(:standard);

$target="http://www.mysite.com/thankyou.html";

print header;
open (ALLUSERS, ">>/c5/jmpservemaillist.txt") || die "cannot open mydatafile: $!\n";open mydatafile: $!\n";
print ALLUSERS scalar (localtime)"^", "$fname^", "$lname^", "$firm^", "$email", "\n";
close (ALLUSERS);

print redirect( -uri=>$target );


And here's the error message I get:

Global symbol "$target" requires explicit package name at /c5/jmpserv/cgi-bin/jmpemail.cgi line 8.
String found where operator expected at /c5/jmpserv/cgi-bin/jmpemail.cgi line 13, near ")"^""
(Missing operator before "^"?)
syntax error at /c5/jmpserv/cgi-bin/jmpemail.cgi line 13, near ")"^""
Global symbol "$fname" requires explicit package name at /c5/jmpserv/cgi-bin/jmpemail.cgi line 13.
Global symbol "$lname" requires explicit package name at /c5/jmpserv/cgi-bin/jmpemail.cgi line 13.
Global symbol "$firm" requires explicit package name at /c5/jmpserv/cgi-bin/jmpemail.cgi line 13.
Global symbol "$email" requires explicit package name at /c5/jmpserv/cgi-bin/jmpemail.cgi line 13.
/c5/jmpserv/cgi-bin/jmpemail.cgi had compilation errors.


I'd appreciate any help.

Reply With Quote
  #2  
Old June 13th, 2001, 08:25 PM
dkode dkode is offline
PHP/PERL/.NET Coder
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Location: Daytona Beach, Florida
Posts: 36 dkode User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 41 sec
Reputation Power: 8
Send a message via AIM to dkode
uh, strict momma

Since you are doing: use strict;
You must declare variables before you use them. Read some documentation on "use strict;"

An example would be this:

instead of
$target = "http://targeturl.com";

you would do
my $target = "http://targeturl.com";

and for $fname and all of your other variables you must declare them first by simple doing:
my $fname;
my $lname;

That is the whole purpose behind strict is forcing you to declare things before you use them that way it eliminates alot of errors. If you want a good tutorial on strict, go to www.perlmonks.org and search for: use strict

Hope this helps,

DKode
__________________
"Mankind cannot define memory, yet it defines mankind"

Reply With Quote
  #3  
Old June 13th, 2001, 11:33 PM
writhe writhe is offline
Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2001
Location: Houston
Posts: 9 writhe User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Talking

dkode-

Thanks, momma. Like I said, I'm a total newbie. You are the m$#*& f@*&%'in man. Thank you.

Reply With Quote
  #4  
Old June 14th, 2001, 03:14 PM
writhe writhe is offline
Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2001
Location: Houston
Posts: 9 writhe User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
problem with redirection

Okay, I've got the script to work except for the redirection to a new page. The script does not work with the redirection bit in there. If I take it out it runs fine. Why won't the redirection work?

#!/usr/bin/perl -w

use strict;
use CGI qw(:all);
use diagnostics;

my $fname=param('fname');
my $lname=param('lname');
my $firm=param('firm');
my $email=param('email');
my $target="http://www.mysite.com/thankyou.html"

print header;
open (ALLUSERS, ">>/c5/jmpserv/email.txt") || die "cannot open mydatafile: $!\n";
print ALLUSERS "$fname*", "$lname*", "$firm*", "$email", "\n";
close (ALLUSERS);

print redirect( -uri => $target);

Reply With Quote
  #5  
Old June 14th, 2001, 04:16 PM
dkode dkode is offline
PHP/PERL/.NET Coder
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Location: Daytona Beach, Florida
Posts: 36 dkode User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 41 sec
Reputation Power: 8
Send a message via AIM to dkode
I'm not sure about the redirect with CGI.pm.

Normally when I want to redirect I just do:

print "Location: http://url.to.redirect.to/\n\n";

And that will redirect them to that specific page.

If you go to perldoc.com and search for cgi.pm you'll find what you need.

Hope this helps!

DKode

Reply With Quote
  #6  
Old June 14th, 2001, 04:21 PM
writhe writhe is offline
Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2001
Location: Houston
Posts: 9 writhe User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks again, dkode.

Reply With Quote
  #7  
Old June 14th, 2001, 05:38 PM
writhe writhe is offline
Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2001
Location: Houston
Posts: 9 writhe User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
closed header?

Well, after looking around perlmonks it seems like a lot of people have had problems with redirection/location. I've put in the bit you told me but rather than redirect to the new page, the actual line of code is written. From what I gather this is happening because the header has already been closed. Is this correct? If so, what do I need to do to keep the header open and thus make the redirect work?

Reply With Quote
  #8  
Old June 15th, 2001, 09:49 AM
mullaney mullaney is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Posts: 0 mullaney User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Writhe,

The redirect command you're using should not be used along with the header. Try removing the "print header;" bit of code.

Bob

Reference

Reply With Quote
  #9  
Old June 15th, 2001, 09:56 AM
writhe writhe is offline
Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2001
Location: Houston
Posts: 9 writhe User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
thanks, man

mullaney-

Wow. I was under the impression I had to print the header to get the data from the form. It is working great now. Thanks.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > newbie with form problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway