943,722 Members | Top Members by Rank

Ad:
  • Perl Discussion Thread
  • Unsolved
  • Views: 1939
  • Perl RSS
You are currently viewing page 1 of this multi-page discussion thread
Jul 29th, 2008
0

Proper Setup?

Expand Post »
I'm trying to access a cgi script when a form is submitted. With that script, I want to display a page that basically says, "Is this info correct?" and show them what they entered. Then, if they hit "Yes", I want to send an email to myself with their info. If no, I want it to go back to the previous page. I'm not sure how to do this. I'm stuck after creating the confirmation page. Here's what I have so far:

Perl Syntax (Toggle Plain Text)
  1. #!/usr/bin/perl
  2. #confirmSubscribe.cgi
  3.  
  4.  
  5. print "Content-type: text/html\n\n";
  6. use CGI qw(:standard);
  7. use Mail::Sendmail;
  8. use strict;
  9.  
  10.  
  11. #var declarations
  12. my ($firstName, $lastName, $email, $street, $city, $state, $zip, $msg, %mail);
  13.  
  14.  
  15. #var values
  16. $firstName = param('firstName');
  17. $lastName = param('lastName');
  18. $email = param('email');
  19. $street = param('street');
  20. $city = param('city');
  21. $state = param('state');
  22. $zip = param('zip');
  23.  
  24.  
  25. #create page
  26. sub send
  27. print header;
  28. print <<endHtml;
  29. <html>
  30. <head>
  31. <title>Please confirm your information</title>
  32. <body>
  33. <p>&nbsp;</p>
  34. <p>&nbsp;</p>
  35. <p>&nbsp;</p>
  36. <p align="center" /><h2>Please confirm your information:</h2></p>
  37. <p><font size="4" face="Arial">$firstName $lastName<br />
  38. $email<br />
  39. $street<br />
  40. $city, $state $zip</font></p><br /><br />
  41. <form method="post" action="http://www.sgnscoops.com/Magazines/magazineMain.html">
  42. <input type="submit" value="Yes, it's correct.">
  43. </form><form method="link" action="http://www.sgnscoops.com/cgi-bin/subscriptionSent.cgi">
  44. <input type="button" value="No, I made a mistake.">
  45. </form>
  46. </body>
  47. </html>
  48. endHtml
Similar Threads
Reputation Points: 10
Solved Threads: 0
Junior Poster
kahaj is offline Offline
193 posts
since Sep 2005
Jul 29th, 2008
0

Re: Proper Setup?

And... what? You want us to write the rest for you?
Reputation Points: 18
Solved Threads: 4
Light Poster
chaosprime is offline Offline
46 posts
since Jul 2008
Jul 29th, 2008
0

Re: Proper Setup?

Click to Expand / Collapse  Quote originally posted by kahaj ...
Perl Syntax (Toggle Plain Text)
  1. sub send
  2. print header;
  3. print <<endHtml;
no curly braces after sub send.

Perl Syntax (Toggle Plain Text)
  1. sub send()
  2. {
  3. #code
  4. }

send() is never called in the main body of the cgi.
Last edited by Major Major; Jul 29th, 2008 at 4:48 pm. Reason: typo
Reputation Points: 16
Solved Threads: 2
Light Poster
Major Major is offline Offline
46 posts
since May 2008
Jul 29th, 2008
0

Re: Proper Setup?

...well, okay. If we're actually going to try to critique. Um... nothing whatsoever in the script actually attempts to send an email.

That's kinda the root of my earlier comment. The whole thing isn't even a framework of what's described as the objective; it's a non-functional beginning of some of it. So it seems like the OP isn't asking for debugging assistance or critique so much as to have the rest of his script (his homework?) written for him.
Reputation Points: 18
Solved Threads: 4
Light Poster
chaosprime is offline Offline
46 posts
since Jul 2008
Jul 29th, 2008
0

Re: Proper Setup?

Click to Expand / Collapse  Quote originally posted by chaosprime ...
...well, okay. If we're actually going to try to critique. Um... nothing whatsoever in the script actually attempts to send an email.

That's kinda the root of my earlier comment. The whole thing isn't even a framework of what's described as the objective; it's a non-functional beginning of some of it. So it seems like the OP isn't asking for debugging assistance or critique so much as to have the rest of his script (his homework?) written for him.

Yeah but notice that in the <form> action, different pages are being called as the action, likely the email is being dealt with there. Although I think that the actions are reversed. It makes more sense that Yes should go to the subscriptionSent.cgi and No should go back to the HTML page where the info was entered to begin with.


Perl Syntax (Toggle Plain Text)
  1. <form method="post" action="http://www.sgnscoops.com/Magazines/magazineMain.html">
  2. <input type="submit" value="Yes, it's correct.">
  3. </form><form method="link" action="http://www.sgnscoops.com/cgi-bin/subscriptionSent.cgi">
  4. <input type="button" value="No, I made a mistake.">
  5. </form>
Reputation Points: 16
Solved Threads: 2
Light Poster
Major Major is offline Offline
46 posts
since May 2008
Jul 29th, 2008
0

Re: Proper Setup?

Okay, fair enough.

OP, would you care to post the other scripts this one is referring to?
Reputation Points: 18
Solved Threads: 4
Light Poster
chaosprime is offline Offline
46 posts
since Jul 2008
Jul 29th, 2008
0

Re: Proper Setup?

You should use one script to handle the entire process. But, writing CGI scripts is not a good idea for a person that seems to not have any experience and probably does not understand even the basics of writing secure CGI scripts. I suggest you hire a programmer, one that can demonstrate that they can write a secure CGI script. A script like this should not cost very much. You can post jobs on many websites and take bids from programmers.
Reputation Points: 246
Solved Threads: 67
Practically a Posting Shark
KevinADC is offline Offline
898 posts
since Mar 2006
Jul 29th, 2008
0

Re: Proper Setup?

I agree that processes like this should be written in one script. People always get too hung up on the 'page' paradigm and break processes across scripts in a way that just doesn't help anything.

But, erm, not for nothin'... but how would this guy actually know if a programmer had demonstrated an ability to write a secure CGI script or not?
Reputation Points: 18
Solved Threads: 4
Light Poster
chaosprime is offline Offline
46 posts
since Jul 2008
Jul 29th, 2008
0

Re: Proper Setup?

Ask for references, read comments from previous customers, have their work reviewed by a third party. It would still be possible to be fooled but many of the hire-a-programmer sites do a good job of hooking up customers with good programmers.

They can always try and hack/crack the script to see what happens under various conditions, which is the acid test of any CGI script.
Reputation Points: 246
Solved Threads: 67
Practically a Posting Shark
KevinADC is offline Offline
898 posts
since Mar 2006
Jul 30th, 2008
0

Re: Proper Setup?

First of all, it is not homework. I'm trying to learn Perl. No one is an ace when they first start learning something. I don't want anyone to write the script for me: I wouldn't learn anything that way.

Major, I did accidentaly have the links switched around for the buttons. Also, the "sub send" I forgot to delete before I posted the code.

Chaos, I didn't attempt the email portion yet because I want to make sure that I set it up correctly before doing so.

When "Yes" is clicked, can I just send an email then, or do I need to have another CGI script perform this?
Reputation Points: 10
Solved Threads: 0
Junior Poster
kahaj is offline Offline
193 posts
since Sep 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Perl Forum Timeline: Script to Remove duplicate lines from a text file.
Next Thread in Perl Forum Timeline: What's wrong with this perl error





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC