homepage Welcome to WebmasterWorld Guest from 54.237.98.229
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
Forum Library, Charter, Moderators: coopster & jatar k & phranque

Perl Server Side CGI Scripting Forum

    
struggling beginner has success! Can you help me resolve small issues?
form works, permissions set, don't know enough coding to alter small stuff
beaglechick

5+ Year Member



 
Msg#: 4178634 posted 3:53 pm on Jul 29, 2010 (gmt 0)

Thanks for the help and to the random people out there elsewhere for bits of working code with step by step instructions on putting it online.

So... now that it is working... I'd like to alter a couple of things. The thank you page that comes up... I want to make my own. I can manage that but I don't see where the url gets specified in the script.... (?)

what I see is a sort of raw mini-html page that then has a line that says:

print "Click here to <A HREF=$ENV{'REFERRER'}>Back</A>.\n";

I don't see how to change the value for the REFERRER or if that is some sort of standard thing. When I have the form in action the "back" link shows up in the current thank you page, but it doesn't work. So, whatever this line means, it's not doing it correctly.

I'd prefer to have it take them to a page I made myself, something with the same design and that validates nicely.

I have the same problem with the lines that give people error messages, etc... it will show a page that says to mail their comments to someone but there isn't a working link, obviously... and I have no idea how to change that.

Here is what the error line looks like now:

print "Form input was not proccessed. Please mail your ";
print "remarks to $FORM{submitaddress}\n";


How to I define what the "submitaddress" is?

 

janharders

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 4178634 posted 4:21 pm on Jul 29, 2010 (gmt 0)

The HTTP_REFERER (just REFERRER probably won't work, also, note that they left out one R when forming the standard) is a special header that the browser sends to the server. It _should_ contain the referring page but you cannot completely rely on that - it's optional.

the whole $FORM{submitaddress} looks like it refers to a field in the form. That's not really a good way to do it because a spammer might manipulate the script into sending spam to his victims. IIRC, the nms cgi scripts were pretty good, reasonably secure and easy to install and configure, maybe you should take a look at those.

beaglechick

5+ Year Member



 
Msg#: 4178634 posted 2:14 am on Jul 30, 2010 (gmt 0)

Part of the problem is the hosting service used by this NPO client. They have crappy tech support and worse documentation. I don't know why but the referring page link comes back as the script file instead of the webpage it started from.

I am working through the nms scripts now... so much easier when people add clear instructions.

Is there a good place to start to learn PERL?

phranque

WebmasterWorld Administrator phranque us a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



 
Msg#: 4178634 posted 2:34 am on Jul 30, 2010 (gmt 0)

the Perl books at O'Reilly Media [oreilly.com] are generally top-notch and many are written by the recognized experts in the field.
for your purposes i would suggest the CGI Programming with Perl book specifically and the Learning Perl book in general.

there are links to an extensive set of web references in the Perl Server Side CGI Scripting forum Charter [webmasterworld.com]

rocknbil

WebmasterWorld Senior Member rocknbil us a WebmasterWorld Top Contributor of All Time 5+ Year Member



 
Msg#: 4178634 posted 4:57 pm on Jul 30, 2010 (gmt 0)

The thank you page that comes up... I want to make my own. I can manage that but I don't see where the url gets specified in the script.... (?)


It may not be a URL. Sometimes it is, and if this is the case look for

print "Location:$url\n\n";

Or similar, look for "location." Which is really a bad way to do a thank you. Most often you will see a general process like

&cleanse_data;
&email_data;
&print_response;

Or, those may be "inline," executing from top to bottom. The advantage here is you can customize it, like

"Thank you for your submission, John Doe . . . . "

Whatever text appears on your thank you response, search your script for it, this will tell you where it is in this case.

what I see is ... print "Click here to <A HREF=$ENV{'REFERRER'}>Back</A>.\n";


This is your "thank you?" This tells me it's in the script, inline. This is really a lame and unfriendly approach. :-) And if your form is encapsulated in the script, it will indeed lead back to itself, or at best, the form if it's separate from the script.

Right where that line is, try this:

#print "Click here to <A HREF=$ENV{'REFERRER'}>Back</A>.\n";
print "this is my response";

Note the #, that is a comment and makes perl ignore that line. If that works and you see "this is my response," you can do this:

$response = qq|
<html><head><title>Thank You</title></head>
<body>
<h1>Thank You</h1>
<p>Thank you for your submission, $FORM{'first_name'}.</p>
</body>
</html>
|;

print $response;

What did I do there? I used qq with the delimiters | to store the entire response in $response, which will allow you to use the form variables to customize the message (look at your form input, I guessed at 'first_name'.) Then we print it out as one block. You know how to do HTML, you can customise everything between the || to customize your response. Just be wary of any delimiters within the text block, for example, if you do

<a href="about/html">About</a> | <a href="/">Home</a>

It will end the block early and error. Escape it.

<a href="about/html">About</a> \| <a href="/">Home</a>

I have the same problem with the lines that give people error messages, etc...


As mentioned, this is a BAD way to do the send-to. We'd have to see a lot more of the script to solve it.

While it's true there are many prepackaged and likely better scripts available, this is how you learn, by picking one apart and experimenting, keep at it. It will start to soak in.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved