Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Coding Forum


You are currently viewing our Coding Forum as a guest. Please register to participate.
Login



Closed Thread
CGI Help DESPERATELY required!
Old 07-20-2004, 10:16 AM CGI Help DESPERATELY required!
LizzeyDripping's Avatar
Skilled Talker

Posts: 77
Name: Sarah
Trades: 0
I have been trying and failing to establish HOW I set up a form to allow people to email me their details. I know that most people use PHP (whatever that is) but that my host does not support this. I know then that I need to use cgi, but I do not have cgi or perl installed on my system - but i don't know if I need to have this in order to write my form and the associated script.

I have designed and produced the form using Dreamweaver MX 2004 and from what I have been able to gather, I now need to put, in the "action" field, the location of my .cgi file so that my form will know what to do. I am not sure then how it will know where to email the form to (please advise where I add this info!) , or how I can then get it to go to a "thank you" page etc . I have seen a million and one Form Wizard sites, but my host doesn't support 3rd party scripts, which I guess (and I do mean I am guessing!) means I must have my own .cgi file saved somewhere in my site structure.

PLEASE - from what I can gather this is something that should be a straightforward exercise, can anyone please help me put together a .cgi script for my form? The code for the form is below. PLEASE, PLEASE, some kind soul with a bit of time on your hands - can you help me? I have followed various links to 'easy to use' .cgi script pages and it might as well be in Latin for all the sense I can make of it.

If anyone can at least suggest a site that doesn't jargonise the c*$p out of everything - I just need to know that I insert my html form here, I put my email address here, I put the location of my thank you page here and then it will work fine!

And I'd like the moon on a stick too, while I'm here please...!

Seriously though, any help gratefully appreciated!

Code below:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Watching Service Enquiry</title>
<style type="text/css">
<!--
body,td,th {
font-family: Verdana;
font-size: 0.8em;
}
body {
background-color: #ffffff;
}
.formTitles {
color: #ffffff;
}
-->
</style></head>

<body>
<form action="" method="post" name="WatchServiceEnquiry" target="_blank" id="WatchServiceEnquiry">
<table width="400" border="0" align="center" cellpadding="10" bgcolor="#86b4d7">
<tr>
<td valign="top" class="formTitles">Name:</td>
<td><input name="Name" type="text" id="Name" maxlength="40"></td>
</tr>
<tr>
<td valign="top" class="formTitles">Email Address: </td>
<td><input name="Email" type="text" id="Email" maxlength="40"></td>
</tr>
<tr>
<td valign="top" class="formTitles">Mark To Be Watched: </td>
<td><input name="MarkDetails" type="text" id="MarkDetails" maxlength="60"></td>
</tr>
<tr>
<td valign="top" class="formTitles">Product/Service Category: </td>
<td><input name="textfield" type="text" maxlength="60"></td>
</tr>
<tr>
<td valign="top" class="formTitles">Additional Comments: </td>
<td><textarea name="Comments" rows="6" id="Comments"></textarea></td>
</tr>
<tr>
<td valign="top" class="formTitles">&nbsp;</td>
<td><input type="checkbox" name="checkbox" value="checkbox"></td>
</tr>
</table>
</form>
</body>
</html>
LizzeyDripping is offline
View Public Profile Visit LizzeyDripping's homepage!
 
 
Register now for full access!
Old 07-20-2004, 11:14 AM
witchblade32's Avatar
Super Talker

Posts: 140
Location: Lititz, PA
Trades: 0
A lot of people use Formmail to process cgi forms. It's available at http://www.scriptarchive.com/formmail.html with all the instruction on setting it up. You would only need to make minor adjustments to your existing form (adding hidden variable with the email you'd like to send to and where to return the user after they submit)

Just take a deep breath and read over it carefully.
__________________
When you eliminate all other possibilities, what remains, no matter how improbable, is the answer.
witchblade32 is offline
View Public Profile Visit witchblade32's homepage!
 
Old 07-20-2004, 11:43 AM
Veter's Avatar
Super Talker

Posts: 147
Trades: 0
If you have PHP at your hosting, then better use php. Its more easy to use and much faster and configurable.
__________________
-=
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
=-
Veter is offline
View Public Profile Visit Veter's homepage!
 
Old 07-20-2004, 11:46 AM
Kyrnt's Avatar
The Post-Mod Years

Posts: 2,536
Location: Western Maryland
Trades: 0
Quote:
Originally Posted by Veter
If you have PHP at your hosting, then better use php. Its more easy to use and much faster and configurable.
The original post indicated that the host does not support PHP.

That said, I would recommend finding a host that does. One must seriously consider the quality of host who does not by this point in time support PHP.
__________________
—Kyrnt
Kyrnt is offline
View Public Profile Visit Kyrnt's homepage!
 
Old 07-20-2004, 11:56 AM
Veter's Avatar
Super Talker

Posts: 147
Trades: 0
Oops... I've missed that.

You right Kyrnt. Thats weird. All good hosters should support php.
__________________
-=
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
=-
Veter is offline
View Public Profile Visit Veter's homepage!
 
Old 07-20-2004, 12:12 PM 123-reg
LizzeyDripping's Avatar
Skilled Talker

Posts: 77
Name: Sarah
Trades: 0
Thanks for your suggestions so far! I was a bit surprised myself that 123-reg don't support PHP as I was told that they are one of the biggest hosting companies in the UK.

I have now looked at the FormMail.pl document again and I honestly have no idea what to do! I just don't understand the jargon used in the ReadMe files - can someone tell me in plain English what "@referers = ( 'scriptarchive.com', 'YOUR_IP'); this array allows you to define the domains on which you allow forms to reside and use this installation of FormMail" means to me in real terms? Do I need to put the email address I want forms sent to in here? Or the address of my host? Do I need to change the bit that says 'scriptarchive.com' to read '123-reg.co.uk' or do I change the bit with the underscore? Do I need to keep the underscore and if so where in the address do I put it?

I have no way of testing whether the form is working until it goes 'live' anyway, which is not so good - apparently the server I will be loading this onto takes 24 hours to update each time, so without being able to test it, I am just in a panic about it not working and want to make sure I am doing everything right - if I'm not my boss is going to come down on me like a ton of bricks - if you think I'm dense at this, he's just told me he doesn't see what's so hard about pressing a button and sending an email 'cos he does it in Outlook every day. I really don't understand what I am doing, though, as must be apparent!

I really need a jargon free, hold your hand and walk you through it type tutorial thing to allow me to use my own form but just add the relevant bits of code to make it do what I want, so if anyone could suggest one that'd be great!

Please help - it'll be great for your karma!
LizzeyDripping is offline
View Public Profile Visit LizzeyDripping's homepage!
 
Old 07-20-2004, 12:35 PM
Veter's Avatar
Super Talker

Posts: 147
Trades: 0
put in that line your domain. @referers = ("yourdomain.com")

This setting is used for security reasons. The script will not accept the form posted from another domains or IPs. It will only accept the form from your domain. No body else can copy your form to their PC, change the code of the form and send it to the script.
__________________
-=
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
=-
Veter is offline
View Public Profile Visit Veter's homepage!
 
Old 07-21-2004, 05:01 AM Thanks
LizzeyDripping's Avatar
Skilled Talker

Posts: 77
Name: Sarah
Trades: 0
OK, thanks - I was confused by the fact that it says your_ip - whether this meant internet provider...

Don't know why I am finding this so baffling!

Thanks for all your help guys!
LizzeyDripping is offline
View Public Profile Visit LizzeyDripping's homepage!
 
Old 07-21-2004, 05:39 AM OK, I'm back...
LizzeyDripping's Avatar
Skilled Talker

Posts: 77
Name: Sarah
Trades: 0
I have used a form wizard program to get this code - I have saved it as watchservice.pl and believe I now just have to upload it to anywhere on my site - I'm a bit worried that I might have to save it as a .cgi file for it to execute though - my host says that any .cgi files will automatically be executed wherever they are saved, so I don't need to put it in the cgi bin apparently.

Can anyone tell me whether it will work if I just resave this file and call it watchservice.cgi instead? Or will that muck it up?

Also, I have two forms on different pages on my site, and have created a different .pl file for each of the forms - that's OK is it?

The wizard said I had to save the file as chfeedback.pl, but as I wanted two files, I had to change the names - I think I have located and changed the right bit in the code to account for the change of name, but I am pasting watchservice.pl below - you have been so good so far - could someone cast a practised eye over it for me?!

Thanks!

#!/usr/bin/perl

##!/usr/bin/perl
# chfeedback.pl Feedback Form Perl Script Ver 2.01
# Generated by thesitewizard.com's Feedback Form Wizard.
# Copyright 2000-2003 by Christopher Heng. All rights reserved.
#
# thesitewizard and thefreecountry are trademarks of Christopher Heng.
# $Id: perlscript.txt 1.1 2003/04/17 11:53:45 chris Exp $
#
# Get the latest version, free, from:
# http://www.thesitewizard.com/wizards/feedbackform.shtml
#
# You can contact me through:
# http://www.thesitewizard.com/feedback.php
#
#
# LICENCE TERMS
#
# 1. You may use this script on your website, with or
# without modifications, free of charge.
#
# 2. You may NOT distribute or republish this script, whether
# modified or not. The script is meant for your personal use
# on your website, and can only be distributed by the author,
# Christopher Heng.
#
# 3. THE SCRIPT AND ITS DOCUMENTATION ARE PROVIDED
# "AS IS", WITHOUT WARRANTY OF ANY KIND, NOT EVEN THE
# IMPLIED WARRANTY OF MECHANTABILITY OR FITNESS FOR A
# PARTICULAR PURPOSE. YOU AGREE TO BEAR ALL RISKS AND
# LIABILITIES ARISING FROM THE USE OF THE SCRIPT,
# ITS DOCUMENTATION AND THE INFORMATION PROVIDED BY THE
# SCRIPTS AND THE DOCUMENTATION.
#
# If you cannot agree to any of the above conditions, you
# may not use the script.
#
# Although it is NOT required, I would be most grateful
# if you could also link to us at:
#
# http://www.thesitewizard.com/
#


# ---------- USER CONFIGURATION SECTION ---------------
# Before this script will do anything useful, the following
# variables must be set.
#
# MANDATORY VARIABLES
# $mailprog - the location of your mail program and the parameters
# to pass to it.
# eg $mailprog = "/usr/lib/sendmail" ;
# $mailto - email address where the feedback will be sent
# eg, $mailto = 'yourname@example.com' ;
# $subject - the subject line in the email sent by the feedback form
# eg $subject = "Feedback Form" ;
#
# $formurl - the URL of your feedback form
# eg $formurl = "http://www.example.com/feedback.html" ;
# $thankyouurl - the URL of your thank you page
# eg $thankyouurl = "http://www.example.com/thanks.html" ;
# $errorurl - the URL of your error page
# eg $errorurl = "http://www.example.com/error.html" ;


$mailprog = "/usr/lib/sendmail" ;
$mailto = 'info@gwwtrademarks.com' ;
$subject = "Watch Service Enquiry" ;
$formurl = "http://www.gwwtrademarks.com/watchservice.html" ;
$errorurl = "http://www.gwwtrademarks.com/error.html" ;
$thankyouurl = "http://www.gwwtrademarks.com/thankyou.html" ;


# ---------- END OF USER CONFIGURATION SECTION ------------

# ---------- functions -----------
sub redirect_url {
my ( $url ) = shift ;
print "Location: $url\n\n" ;
}

sub parse_form_data {
my ($request_method, $input_string, $content_length) ;
my (@vars, $indiv_var, $name, $value);
my (%form) ;

$request_method = $ENV{'REQUEST_METHOD'} ;
$content_length = $ENV{'CONTENT_LENGTH'} ;

# load the entire string into $input_string
if ($request_method =~ /post/i) {
$input_string = "" ;
read( STDIN, $input_string, $content_length ) ;
}
else {
$input_string = $ENV{ 'QUERY_STRING' };
}
unless (defined $input_string) {
$input_string = "" ;
}

# put all the variable pairs (name=value) into an array
@vars = split( /&/, $input_string );

# process each individual name, value pair, putting them
# into a hash for easy access
foreach $indiv_var ( @vars ) {

# separate the pair
($name, $value) = split( /=/, $indiv_var, 2 );

# translate encoding
$name =~ s/%([\da-fA-F]{2})/pack("C", hex($1))/eg;
$name =~ tr/+/ /;
unless (defined $value) {
# just in case there was no equals as in ISINDEX
$value = "" ;
}
$value =~ s/%([\da-fA-F]{2})/pack("C", hex($1))/eg;
$value =~ tr/+/ /;

# put the pair in the hash for easy access
$form{$name} = $value ;
}

return wantarray ? %form : undef ;
}

sub send_email {
my ($mailprog, $email, $name, $mailto, $subject, $message) = @_ ;

if (open MAIL, "|$mailprog -t") {
print MAIL "To: $mailto\n" ;
print MAIL "From: \"$name\" <$email>\n" ;
print MAIL "Reply-To: \"$name\" <$email>\n" ;
print MAIL "X-Mailer: watchservice.pl 2.01\n" ;
print MAIL "Subject: $subject\n\n" ;
print MAIL $message ;
close MAIL ;
}
# ignore fails, just don't do anything

return ;
}

# ----------- main program ------

my %form = parse_form_data();

my $email ;
if (exists $form{"email"}) {
$email = $form{"email"} ;
}
else {
redirect_url( $formurl );
exit ;
}
if ($email eq "") {
redirect_url( $errorurl );
exit ;
}

my $name = $form{"name"} ;
if ($name eq "") {
redirect_url( $errorurl );
exit ;
}

my $comments = $form{'comments'} ;
if ($comments eq "") {
redirect_url( $errorurl );
exit ;
}

my $http_referer = $ENV{ 'HTTP_REFERER' };
my $message =
"This message was sent from:\n" .
"$http_referer\n" .
"------------------------- COMMENTS -------------------------\n\n" .
$comments .
"\n\n------------------------------------------------------------\n" ;

send_email ( $mailprog, $email, $name, $mailto, $subject, $message );
redirect_url( $thankyouurl );
LizzeyDripping is offline
View Public Profile Visit LizzeyDripping's homepage!
 
Closed Thread     « Reply to CGI Help DESPERATELY required!
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 1.02705 seconds with 12 queries