Proper Setup?

Reply

Join Date: Sep 2005
Posts: 175
Reputation: kahaj is an unknown quantity at this point 
Solved Threads: 0
kahaj kahaj is offline Offline
Junior Poster

Proper Setup?

 
0
  #1
Jul 29th, 2008
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:

  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
Be what you is, don't be what you ain't.
Cause if you ain't what you is, you is what you ain't!
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 46
Reputation: chaosprime is an unknown quantity at this point 
Solved Threads: 4
chaosprime's Avatar
chaosprime chaosprime is offline Offline
Light Poster

Re: Proper Setup?

 
0
  #2
Jul 29th, 2008
And... what? You want us to write the rest for you?
Chaos
Lost Souls: text based RPG
MUDseek: MUD gaming search
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 46
Reputation: Major Major is an unknown quantity at this point 
Solved Threads: 2
Major Major Major Major is offline Offline
Light Poster

Re: Proper Setup?

 
0
  #3
Jul 29th, 2008
Originally Posted by kahaj View Post
  1. sub send
  2. print header;
  3. print <<endHtml;
no curly braces after sub send.

  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
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 46
Reputation: chaosprime is an unknown quantity at this point 
Solved Threads: 4
chaosprime's Avatar
chaosprime chaosprime is offline Offline
Light Poster

Re: Proper Setup?

 
0
  #4
Jul 29th, 2008
...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.
Chaos
Lost Souls: text based RPG
MUDseek: MUD gaming search
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 46
Reputation: Major Major is an unknown quantity at this point 
Solved Threads: 2
Major Major Major Major is offline Offline
Light Poster

Re: Proper Setup?

 
0
  #5
Jul 29th, 2008
Originally Posted by chaosprime View Post
...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.


  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>
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 46
Reputation: chaosprime is an unknown quantity at this point 
Solved Threads: 4
chaosprime's Avatar
chaosprime chaosprime is offline Offline
Light Poster

Re: Proper Setup?

 
0
  #6
Jul 29th, 2008
Okay, fair enough.

OP, would you care to post the other scripts this one is referring to?
Chaos
Lost Souls: text based RPG
MUDseek: MUD gaming search
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 898
Reputation: KevinADC has a spectacular aura about KevinADC has a spectacular aura about 
Solved Threads: 67
KevinADC's Avatar
KevinADC KevinADC is offline Offline
Practically a Posting Shark

Re: Proper Setup?

 
0
  #7
Jul 29th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 46
Reputation: chaosprime is an unknown quantity at this point 
Solved Threads: 4
chaosprime's Avatar
chaosprime chaosprime is offline Offline
Light Poster

Re: Proper Setup?

 
0
  #8
Jul 29th, 2008
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?
Chaos
Lost Souls: text based RPG
MUDseek: MUD gaming search
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 898
Reputation: KevinADC has a spectacular aura about KevinADC has a spectacular aura about 
Solved Threads: 67
KevinADC's Avatar
KevinADC KevinADC is offline Offline
Practically a Posting Shark

Re: Proper Setup?

 
0
  #9
Jul 29th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Sep 2005
Posts: 175
Reputation: kahaj is an unknown quantity at this point 
Solved Threads: 0
kahaj kahaj is offline Offline
Junior Poster

Re: Proper Setup?

 
0
  #10
Jul 30th, 2008
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?
Be what you is, don't be what you ain't.
Cause if you ain't what you is, you is what you ain't!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC