![]() |
|
|
#1 (permalink) |
|
Registered User
Join Date: Sep 2006
Posts: 8
|
Please don't laugh because I think my problem will stand on record as the most basic ever to be posted asking for scripting support, but please bear with me because I'm a keen newbie!
I've created a simple form (well, downloaded it from www.bignosebird.com) and put the cgi file in my cgi-bin. The problem is (I think) that I cant get the form to speak to the cgi file. I have the action as: http://mydomain.com/wwwroot/cgi-bin/bnbform.cgi I'm using dreamweaver 8 and have windows rather than linux. Can anyone who is kind enough to reply, please keep the answer really simple (when they stop laughing)! Any help will be very much appreciated! Thanx, Headspin The script reads: #!/usr/bin/perl use Socket; ################################################## ################ # (C)1998-2000 Bignosebird.com bnbform v4.0 # Use of this script means that you accept the disclaimer and # agree to the terms of use located at the bottom of the # script. # # Updated January 31, 2000 # # This script is provided without support. Please read the # README.TXT file, as well as following the troubleshooting # links and information at http://bignosebird.com/cgi.shtml # Our BBS is located at http://bignosebird.com/bbs.shtml # # Socket based e-mail for cross platform capability! # # Attention users of earlier versions of BNBFORM- # You MUST read the README.TXT file to know how to configure # your forms for use with this new version. Otherwise your # logfile, countfile, autorespond, etc... will stop working. # It was necessary to make these changes for security reasons. # # ############## SPECIAL FORM VARIABLES ############################ #required: comma delimited list of required entry fields #data_order: comma delimited list indicating what fields to actually # print and in what order. #outputfile: the name of the file to save the data in if using a file. # the file will automatically be named ending with .bout #emailfile: the name of the file to hold only the sender e-mail address # the file will automatically be named ending with .bemf #ok_url: URL to go to if successful #not_ok_url URL to go to if unsuccessful #submit_to: email address of person to input receive data by mail # this can be a comma seperated list of e-mail addresses #cc_to: email address of Cc Recipient # this can be a comma seperated list of e-mail addresses #submit_by: email address of person completing form #autorespond: NO LONGER USED AS OF JAN 31, 2000 #automessage: text to print for autoconfirmation e-mail # the file will automatically be named ending with .baut #form_id: name of form for e-mail subject #countfile: name of file for serial number counter # the file will automatically be named ending with .bcnt #okaydomains: prevents calling the script from other sites, # without restricting e-mail addresses. # replaces $SECURE_NAME from earlier versions. # use only lower case letters. #SMTP_SERVER: the full host name of the server providing e-mail # gateway service ################################################## ################ ## MAIN ################################################## ######## # uncomment the line below, and change bignosebird to your domain # name if you wish to make is so the script can only be called # from your site. @okaydomains=("http://mydomain.com", "http://www.mydomain.com"); #SMTP_SERVER: indicates the name of the host acting as the e-mail # gateway. "localhost" should work on most systems. $SMTP_SERVER="localhost"; #OR IF SMTP IS UNAVAILABLE TO YOU, USE SEND_MAIL-; #$SEND_MAIL="/usr/lib/sendmail -t"; $lockfile="/tmp/bnbform.lck"; $SD=&sys_date; $ST=&sys_time; &decode_vars; &valid_page; if ($fields{'countfile'} ne "") { &get_number; } &valid_data; &write_data; if ($fields{'automessage'} ne "") { &answer_back; } if ($fields{'ok_url'} ne ""){ print "Location: $fields{'ok_url'}\n\n"; exit; } else { &thank_you; } ################################################## ################ sub write_data { if ($fields{'submit_by'} ne "") { if (&valid_address == 0) { &bad_email; exit; } } if ($fields{'submit_by'} ne "" && $fields{'emailfile'} ne "") { open (EMF,">>$fields{'emailfile'}"); print EMF "$fields{'submit_by'}\n"; close (EMF); } if ($fields{'submit_to'} ne "") { $msgtext=""; $msgtext .= "On $SD at $ST,\n"; $msgtext .= "The following information was submitted:\n"; $msgtext .= "From Host: $ENV{'REMOTE_ADDR'}\n"; } if ($fields{'outputfile'} ne "") { &get_the_lock; open(OUT_FILE,">>$fields{'outputfile'}"); } foreach $to_print (@sortlist) { if ($fields{'outputfile'} ne "") { print OUT_FILE "$fields{$to_print}\|"; } if ($fields{'submit_to'} ne "") { $msgtext .= "$to_print = $fields{$to_print}\n"; } } if ($fields{'outputfile'} ne "") { print OUT_FILE "$SD\|$ST\|\n"; close(OUT_FILE); &drop_the_lock; } foreach $to_get (@recipients) { $mailresult=&sendmail($fields{submit_by}, $fields{submit_by}, $to_get, $SMTP_SERVER, $fields{form_id}, $msgtext); if ($mailresult ne "1") { print "Content-type: text/html\n\n"; print "MAIL NOT SENT. SMTP ERROR: $mailcodes{'$mailresult'}\n"; exit } } foreach $to_cc (@cc_tos) { $mailresult=&sendmail($fields{submit_by}, $fields{submit_by}, $to_cc, $SMTP_SERVER, $fields{form_id}, $msgtext); if ($mailresult ne "1") { print "Content-type: text/html\n\n"; print "MAIL NOT SENT. SMTP ERROR: $mailcodes{'$mailresult'}\n"; exit } } } ################################################## ################ sub decode_vars { $i=0; read(STDIN,$temp,$ENV{'CONTENT_LENGTH'}); @pairs=split(/&/,$temp); foreach $item(@pairs) { ($key,$content)=split(/=/,$item,2); $content=~tr/+/ /; $content=~s/%(..)/pack("c",hex($1))/ge; $content=~s/\t/ /g; $content=~s/\0//g; #strip nulls $fields{$key}=$content; if ($key eq "data_order") { $content=~s/\012//g; $content=~s/\015//g; $content=~s/ //g; $content=~s/ //g; @sortlist=split(/,/,$content); } if ($key eq "required") { $content=~s/\012//g; $content=~s/\015//g; $content=~s/ //g; @mandatory=split(/,/,$content); } if ($key eq "submit_to") { $content=~s/\012//g; $content=~s/\015//g; $content=~s/ //g; @recipients=split(/,/,$content); } if ($key eq "cc_to") { $content=~s/\012//g; $content=~s/\015//g; $content=~s/ //g; @cc_tos=split(/,/,$content); } } if ( ( ($fields{automessage}=~ /^([-\/\w.]+)$/ || $fields{automessage} eq "") && ($fields{countfile}=~ /^([-\/\w.]+)$/ || $fields{countfile} eq "") && ($fields{emailfile}=~ /^([-\/\w.]+)$/ || $fields{emailfile} eq "") && ($fields{outputfile}=~ /^([-\/\w.]+)$/ || $fields{outputfile} eq "") ) ) {$donothing=0;} else { print "Content-type: text/html\n\n sorry, invalid characters...\n"; exit; } if ($fields{automessage} ne "") {$fields{automessage} .= ".baut";} if ($fields{countfile} ne "") {$fields{countfile} .= ".bcnt";} if ($fields{emailfile} ne "") {$fields{emailfile} .= ".bemf";} if ($fields{outputfile} ne "") {$fields{outputfile} .= ".bout";} } ################################################## ################ sub valid_data ...and so it goes on, but the forum only allows 1000 characters per post. Hope this is enough! |
|
|
|
|
|
#2 (permalink) |
|
Administrator
Join Date: May 2003
Posts: 1,299
|
Hi Headspin,
We all have to learn somehow! Try setting it up to navigate to: http://mydomain.com/cgi-bin/bnbform.cgi rather than http://mydomain.com/wwwroot/cgi-bin/bnbform.cgi Regards, Jacob
__________________
Jacob Colton jacob@catalyst2.com Open a ticket | Knowledgebase | Rate catalyst2 | Review catalyst2 |
|
|
|
|
|
#3 (permalink) |
|
Registered User
Join Date: Sep 2006
Posts: 8
|
Hello Jacob,
Thanks for such a fast reply. Doing as you advised has got me to the point where when I hit the send button on my form, I get the following: MAIL NOT SENT. SMTP ERROR: on an otherwise blank window in Explorer. Can you think of anything else? Headspin. |
|
|
|
|
|
#4 (permalink) |
|
Administrator
Join Date: May 2003
Posts: 1,299
|
Ah, you are using sendmail - this will not work on windows accounts. to send emails on a windows account, you will need to use something like CDONTS.
You can see an example at: http://www.4guysfromrolla.com/webtec...ail/faq2.shtml Regards, Jacob
__________________
Jacob Colton jacob@catalyst2.com Open a ticket | Knowledgebase | Rate catalyst2 | Review catalyst2 |
|
|
|
|
|
#5 (permalink) |
|
Registered User
Join Date: Sep 2006
Posts: 8
|
Where should I paste the CDONTS script, ie.....
<% Dim objMail Set objMail = Server.CreateObject("CDONTS.NewMail") objMail.From = "rob@tconsult.com" objMail.Subject = "How TO send email with CDONTS" objMail.To = "someone@someplace.com" objMail.Body = "This is an email message" & vbcrlf&_ "with CDONTS." & vbcrlf&_ "It is really easy. " objMail.Send Response.write("Mail was Sent") 'You must always do this with CDONTS. set objMail = nothing %> ....into my script posted above, and do I include all of it including the <% bits? I don't think I'm using sendmail because the script on my previous post said.... #SMTP_SERVER: indicates the name of the host acting as the e-mail # gateway. "localhost" should work on most systems. $SMTP_SERVER="localhost"; #OR IF SMTP IS UNAVAILABLE TO YOU, USE SEND_MAIL-; #$SEND_MAIL="/usr/lib/sendmail -t"; ...is "localhost" the right word to use in the above script? Ta, H-S |
|
|
|
|
|
#6 (permalink) |
|
Administrator
Join Date: May 2003
Posts: 1,299
|
Try creating a file with just:
<% Dim objMail Set objMail = Server.CreateObject("CDONTS.NewMail") objMail.From = "rob@tconsult.com" objMail.Subject = "How TO send email with CDONTS" objMail.To = "someone@someplace.com" objMail.Body = "This is an email message" & vbcrlf&_ "with CDONTS." & vbcrlf&_ "It is really easy. " objMail.Send Response.write("Mail was Sent") 'You must always do this with CDONTS. set objMail = nothing %> (changing the email addresses) and save in a file called test.asp and then go to http://www.yourdomain.com/test.asp Regards, Jacob
__________________
Jacob Colton jacob@catalyst2.com Open a ticket | Knowledgebase | Rate catalyst2 | Review catalyst2 |
|
|
|
|
|
#7 (permalink) |
|
Registered User
Join Date: Sep 2006
Posts: 8
|
Hello Jacob,
I'm making progress. I did as you said and when I clicked on the go icon at the right of the address bar in Explorer, it generated a message to me confirming that a message had been sent. Sure enough, an e-mail was received by me with the expected text in it. But how do I go from here to getting a form designed in dreamweaver (which I can do) to appear for the sender to read, fill in and hit a send button? Sorry if i seem to be a mither, but I bet there are lots of people in my position who may benefit from this thread. Cheers, H-S |
|
|
|
|
|
#8 (permalink) |
|
Administrator
Join Date: May 2003
Posts: 1,299
|
I would suggest you have a look at: http://www.w3schools.com/asp/asp_inputforms.asp
__________________
Jacob Colton jacob@catalyst2.com Open a ticket | Knowledgebase | Rate catalyst2 | Review catalyst2 |
|
|
|
|
|
#9 (permalink) |
|
Registered User
Join Date: Sep 2006
Posts: 8
|
Jacob,
Thanks very much for your help. The site you recommended looks very useful. It has a tutorial and even has an example form (extremely simple) that I think I can try to expand. I'm glad I came to Catalyst2 for my hosting & am very impressed with the response times from you. Thanks again, Headspin
|
|
|
|
|
|
#10 (permalink) |
|
Administrator
Join Date: May 2003
Posts: 1,299
|
You are very welcome...
__________________
Jacob Colton jacob@catalyst2.com Open a ticket | Knowledgebase | Rate catalyst2 | Review catalyst2 |
|
|
|
|
|
#11 (permalink) |
|
Registered User
Join Date: Sep 2006
Posts: 8
|
Hello again,
After my hopes were raised, I read on tizag.com's asp tutorial that ASP wont work if like me, you have windows XP. You need XP Pro, so after 24 hours of struggling it looks like I'm back to square one ![]() I hope this info comes in useful for other newbies. Headspin's adventure into this esoteric world of scripts continues! All I want to do is create a form on my website that can be submitted by a visitor and sent to my e-mail (without my visitor getting scarry warning messages about programs wanting to send e-mails). |
|
|
|
|
|
#12 (permalink) |
|
Registered User
Join Date: Sep 2006
Posts: 8
|
getting there with perl/windows
I've now tried using a script generator and I'm getting an error which makes me think my form cant find something.
The error message on submission of the form is.... Software error: Can't locate Win32/OLE.pm in @INC (@INC contains: D:/perl/lib D:/perl/site/lib .) at D:\Domains\mydomain.com\wwwroot\cgi-bin\contact.cgi line 32. BEGIN failed--compilation aborted at D:\Domains\mydomain.com\wwwroot\cgi-bin\contact.cgi line 32. For help, please send mail to this site's webmaster, giving this error message and the time and date of the error. The form is as follows..... <!-- Website Contact Form Generator --> <!-- http://www.tele-pro.co.uk/scripts/contact_form/ --> <!-- This script is free to use as long as you --> <!-- retain the credit link --> <form method="POST" action="/cgi-bin/contact.cgi"> Fields marked (*) are required <p>Email From:* <br> <input type="text" name="EmailFrom"> <p>Name:<br> <input type="text" name="Name"> <p><input type="submit" name="submit" value="Submit"> </form> <p> <!-- Contact Form credit link --> Created by <a target="_blank" href="http://www.tele-pro.co.uk/scripts/contact_form/">Contact Form Generator</a> The cgi script is as follows..... #!/usr/bin/perl use CGI::Carp qw(fatalsToBrowser); use CGI qw(:standard); print "Content-type: text/html \n\n"; # Website Contact Form Generator # http://www.tele-pro.co.uk/scripts/contact_form/ # This script is free to use as long as you # retain the credit link # get posted data into local variables $input = new CGI; $EmailFrom = $input->param('EmailFrom'); $EmailTo = "mail@mydomain.com"; $Subject = "teleprohot"; $Name = $input->param('Name'); # validation $validationOK=true; if ($EmailFrom eq '') {$validationOK=false;} if ($validationOK eq false) { print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; exit; } # prepare email body text $Body .= "Name: "; $Body .= "$Name"; $Body .= "\n"; # send email use Win32::OLE; $ex = Win32::OLE->new('CDONTS.NewMail') or die "\nCDONTS error"; $ex->Send($EmailFrom,$EmailTo,$Subject,$Body); # redirect to success page print "<meta http-equiv=\"refresh\" content=\"0;URL=ok.htm\">"; ***************************** Any ideas would be welcome. Cheers, Headgoingbad |
|
|
|
|
|
#13 (permalink) |
|
Administrator
Join Date: May 2003
Posts: 1,299
|
ASP will definitely work on Windows hosting. The business with Windows XP only matters if you are planning on running a server from your computer - which you are not. If you upload the asp files to the server using FTP they will work a charm. You will find ASP a lot more straight forward than perl.
Regards, Jacob
__________________
Jacob Colton jacob@catalyst2.com Open a ticket | Knowledgebase | Rate catalyst2 | Review catalyst2 |
|
|
|
|
|
#14 (permalink) |
|
Registered User
Join Date: Sep 2006
Posts: 8
|
Jacob,
I'm sure you're right, but I just cant get anywhere with ASP and I seem to be getting further with perl - particularly now that I've found the above neat little form generator. Could you tell me what's wrong with my script above because the equivalent script in ASP got me nowhere. Hope you're not getting fed up with me, but I think this thread may be useful to newbies and a laugh to those who have trodden this weary path before me! Headbashed |
|
|
|
|
|
#15 (permalink) |
|
Administrator
Join Date: May 2003
Posts: 1,299
|
Where can I test the form?
Regards, Jacob
__________________
Jacob Colton jacob@catalyst2.com Open a ticket | Knowledgebase | Rate catalyst2 | Review catalyst2 |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|