|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
CGI File
Can anyone help me alter this cgi file to make it work?
Thanks in advance #!/usr/bin/perl ################################################################################### # IMPORTANT : Anybody can use or distribute this script as long as the # # author's info below stays intact. # # # # AUTHOR's INFO: # # # # WAP-FORMAIL cgi script by UPOINT dotNET ENTERPRISE # # Web: www.upoint.net # # WAP: www.upoint.net/wap # # Email: lawrence@upoint.net # # # # INSTRUCTION: # # You must chmod this script to 755 # # Not many variables needed to be defined as variables are mostly set in the # # WAP contact form. # # # # WAP CONTACT FORM SAMPLE: # # # # <?xml version="1.0"?> # # <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http:// # # www.wapforum.org/DTD/wml_1.1.xml"> # # <wml> # # <card id="WAPContact" title="Send Message"> # # <p> # # Your Name:<input type="text" name="name"/> # # Your Email:<input type="text" name="email"/> # # Select Gender: # # <select name="gender"> # # <option value="Mr">Male</option> # # <option value="Ms">Female</option> # # </select> # # Your Message:<input type="text" name="message"/> # # <anchor> # # Send <go href="http://www.Mobile-Empire.com/cgi-bin/formail.cgi" method="post"> # # <postfield name="name" value="$(name)" /> # # <postfield name="email" value="$(email)" /> # # <postfield name="gender" value="$(gender)" /> # # <postfield name="message" value="$(message)" /> # # <postfield name="site" value="Mobile-Empire" /> # # <postfield name="subject" value="A mail sent from Mobile-Empire WAP site" /> # # <postfield name="your_email" value="webmaster@mobile-empire.com" /> # # <postfield name="home_url" value="http://www.Mobile-Empire.com/index.wml"/> # # </go> # # </anchor> # # </p> # # </card> # # </wml> # # # ################################################################################### # Enter the location of sendmail. $mailprogram = "/usr/sbin/sendmail -t"; # Enter the fields that are required. They should each be in quotes and # separated by a comma. If no fields are required, change the next line # to @required = (); @required = ('name','email','gender','message'); ################################################################################### # Congratulations! You've finished defining the variables. If you want to, # # you can continue screwing with the script, but it isn't necessary. # ################################################################################### # Put the posted data into variables read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $FORM{$name} = $value; } # Check for all required fields foreach $check(@required) { unless ($FORM{$check}) { print "Content-type:text/vnd.wap.wml \n\n\n"; print "<?xml version=\"1.0\"?> <!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\" \"http://www.wapforum.org/DTD/wml_1.1.xml\"> <wml> <card id=\"Result\" title=\"Result\"> <do type=\"prev\" label=\"back\"><prev/> </do> <p>Sorry, you didn't fill the $check field. Please try again.</p> </card> </wml> "; exit; } } # Check the senders email if ($FORM{'email'}) { unless ($FORM{'email'} =~ /\w+@\w+.\w+/) { print "Content-type:text/vnd.wap.wml \n\n\n"; print "<?xml version=\"1.0\"?> <!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\" \"http://www.wapforum.org/DTD/wml_1.1.xml\"> <wml> <card id=\"Result\" title=\"Result\"> <do type=\"prev\" label=\"back\"><prev/> </do> <p>Sorry, the email address $FORM{'email'} is invalid. Please try again.</p> </card> </wml> "; exit; } } open (MAIL,"|$mailprogram"); print MAIL "To: $FORM{'your_email'}\n"; print MAIL "From: $FORM{'email'}\n"; print MAIL "Subject: $FORM{'subject'}.\n"; print MAIL "Message sent by $FORM{'gender'}.$FORM{'name'} from $FORM{'site'} WAP site.\n\n"; print MAIL "Message:\n\n"; print MAIL "$FORM{'message'}\n"; close MAIL; print "Content-type:text/vnd.wap.wml \n\n\n"; print "<?xml version=\"1.0\"?> <!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\" \"http://www.wapforum.org/DTD/wml_1.1.xml\"> <wml> <card id=\"Result\" title=\"Result\"> <do type=\"prev\" label=\"back\"><prev/> </do> <p>Dear $FORM{'gender'}.$FORM{'name'}, thank you for contacting $FORM{'www.Mobile-Empire.com/index.wml'}. We will attend to you soon.</p> <p><a href=\"$FORM{'www.Mobile-Empire.com/index.wml'}\">. . . . Main Menu</a></p> </card> </wml> "; |
|
#2
|
||||
|
||||
|
you could try the oroginal developers site for help
just asking for someone to make something work yet not giving any idea as to why it's not working or the kind of error you get isn't that helpful for people to be able to help you you need to be very specific as to what the error is.
__________________
Andy Moore << oh no it's got a blog..... Word Press WAP Plugin with Ad Mob Advertising revenue PHP developer deploying ringtones, mp3 downloads and realtones I'm a geek who's obsessed with stats and gadgets |
|
#3
|
|||
|
|||
|
Thanks for your reply mate,
Am creating a email contact on WAP site to send direct email to us through WAP, there’s 2 files WML & CGI, the WML file (below) works fine when tested but when clicking on send going to CGI file an error message appears (Invalid WML code). (WML File) <?xml version="1.0"?> <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml"> <wml> <card id="WAPContact" title="Send Message"> <p> Your Name:<input type="text" name="name"/> Your Email:<input type="text" name="email"/> Select Gender: <select name="gender"> <option value="Mr">Male</option> <option value="Ms">Female</option> </select> Your Message:<input type="text" name="message"/> <anchor> Send <go href="http://www.Mobile-Empire.com/cgi-bin/formail.cgi" method="post"> <postfield name="name" value="$(name)"/> <postfield name="email" value="$(email)"/> <postfield name="gender" value="$(gender)"/> <postfield name="message" value="$(message)"/> <postfield name="site" value="UPOINT dotNET ENTERPRISE"/> <postfield name="subject" value="A mail sent from U-Point WAP site"/> <postfield name="your_email" value="webmaster@mobile-empire.com"/> <postfield name="home_url" value="http://www.Mobile-Empire.com/index.wml"/> </go> </anchor> </p> <p>- - - - - - - - -</p> <p><a href="http://www.Mobile-Empire.com/index.wml">Main Menu</a></p> </card> </wml> (CGI File) #!/usr/bin/perl ################################################################################### # IMPORTANT : Anybody can use or distribute this script as long as the # # author's info below stays intact. # # # # AUTHOR's INFO: # # # # WAP-FORMAIL cgi script by UPOINT dotNET ENTERPRISE # # Web: www.upoint.net # # WAP: www.upoint.net/wap # # Email: lawrence@upoint.net # # # # INSTRUCTION: # # You must chmod this script to 755 # # Not many variables needed to be defined as variables are mostly set in the # # WAP contact form. # # # # WAP CONTACT FORM SAMPLE: # # # # <?xml version="1.0"?> # # <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http:// # # www.wapforum.org/DTD/wml_1.1.xml"> # # <wml> # # <card id="WAPContact" title="Send Message"> # # <p> # # Your Name:<input type="text" name="name"/> # # Your Email:<input type="text" name="email"/> # # Select Gender: # # <select name="gender"> # # <option value="Mr">Male</option> # # <option value="Ms">Female</option> # # </select> # # Your Message:<input type="text" name="message"/> # # <anchor> # # Send <go href="http://www.Mobile-Empire.com/cgi-bin/formail.cgi" method="post"> # # <postfield name="name" value="$(name)" /> # # <postfield name="email" value="$(email)" /> # # <postfield name="gender" value="$(gender)" /> # # <postfield name="message" value="$(message)" /> # # <postfield name="site" value="Mobile-Empire" /> # # <postfield name="subject" value="A mail sent from Mobile-Empire WAP site" /> # # <postfield name="your_email" value="webmaster@mobile-empire.com" /> # # <postfield name="home_url" value="http://www.Mobile-Empire.com/index.wml"/> # # </go> # # </anchor> # # </p> # # </card> # # </wml> # # # ################################################################################### # Enter the location of sendmail. $mailprogram = "/usr/sbin/sendmail -t"; # Enter the fields that are required. They should each be in quotes and # separated by a comma. If no fields are required, change the next line # to @required = (); @required = ('name','email','gender','message'); ################################################################################### # Congratulations! You've finished defining the variables. If you want to, # # you can continue screwing with the script, but it isn't necessary. # ################################################################################### # Put the posted data into variables read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $FORM{$name} = $value; } # Check for all required fields foreach $check(@required) { unless ($FORM{$check}) { print "Content-type:text/vnd.wap.wml \n\n\n"; print "<?xml version=\"1.0\"?> <!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\" \"http://www.wapforum.org/DTD/wml_1.1.xml\"> <wml> <card id=\"Result\" title=\"Result\"> <do type=\"prev\" label=\"back\"><prev/> </do> <p>Sorry, you didn't fill the $check field. Please try again.</p> </card> </wml> "; exit; } } # Check the senders email if ($FORM{'email'}) { unless ($FORM{'email'} =~ /\w+@\w+.\w+/) { print "Content-type:text/vnd.wap.wml \n\n\n"; print "<?xml version=\"1.0\"?> <!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\" \"http://www.wapforum.org/DTD/wml_1.1.xml\"> <wml> <card id=\"Result\" title=\"Result\"> <do type=\"prev\" label=\"back\"><prev/> </do> <p>Sorry, the email address $FORM{'email'} is invalid. Please try again.</p> </card> </wml> "; exit; } } open (MAIL,"|$mailprogram"); print MAIL "To: $FORM{'your_email'}\n"; print MAIL "From: $FORM{'email'}\n"; print MAIL "Subject: $FORM{'subject'}.\n"; print MAIL "Message sent by $FORM{'gender'}.$FORM{'name'} from $FORM{'site'} WAP site.\n\n"; print MAIL "Message:\n\n"; print MAIL "$FORM{'message'}\n"; close MAIL; print "Content-type:text/vnd.wap.wml \n\n\n"; print "<?xml version=\"1.0\"?> <!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\" \"http://www.wapforum.org/DTD/wml_1.1.xml\"> <wml> <card id=\"Result\" title=\"Result\"> <do type=\"prev\" label=\"back\"><prev/> </do> <p>Dear $FORM{'gender'}.$FORM{'name'}, thank you for contacting $FORM{'www.Mobile-Empire.com/index.wml'}. We will attend to you soon.</p> <p><a href=\"$FORM{'www.Mobile-Empire.com/index.wml'}\">. . . . Main Menu</a></p> </card> </wml> "; Any help would be appreciated ![]() |
|
#4
|
||||
|
||||
|
have you set the cgi file permissions to 755?
i noticed there is a loop in there "foreach $check(@required) {" that will echo out wap headers for each variable that is missing it's been a long time since i used cgi scripting so i'm totally rusty with it but that's what springs to minds after glancing over it. i'm a big fan of php and have been for a couple of years since the firs time i needed to database something, i've not touched anything cgi since so apologies if my input isn't that great. you could try to call it in a normal browser to see what it outputs, if it is the permissions thing i mentioned it'll error 500. hth |
|
#5
|
|||
|
|||
|
Thanks mate am doing my best but can I chmod of cgi file on windows or does it have to be on a Linux?
|
|
#6
|
||||
|
||||
|
any decent ftp prog should let you do it
i use fetch on a mac to talk upload stuff to our nix box but i've used tpin.com 's ftp before which let me, urgh i feel dirty with this windows talk...... had to use a win machine over the weekend, horrible....... lol good luck! |
|
#7
|
|||
|
|||
|
I've changes the cgi file to 755 but it seems there's nothing wrong with script, I don’t know much about cgi so if anyone can help that would be great
![]() |
|
#8
|
|||
|
|||
|
Double click. sorry
|
|
#9
|
|||
|
|||
|
Try this
Hello.
I have tried your CGI script using my Linux server and I don't get the 500 Internal Server Error. If you are running that script on Windows, you should change the location of Perl runtime on the first line in your CGI script, or your web server could not locate the Perl program. This works fine for Linux/Unix: Code:
#!/usr/bin/perl For Windows, you should use this: Code:
#!perl or something like: Code:
#!c:/perl/bin Try to change this. |
|
#10
|
|||
|
|||
|
Thanks for your reply mate,
I’ve already tried what you’ve suggested on our Linux but still not working ![]() |
|
#11
|
||||
|
||||
|
have you got the right mime types setup in your .htaccess
|
|
#12
|
|||
|
|||
|
Second try
Be sure to save your CGI script in Unix mode, not DOS mode.
DOS mode saves a different EOL, which causes a 500 Internal Error. Probably you already did this, but I say you this because this kind of problem made me crazy long time ago. ![]() |
|
#13
|
|||
|