FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Looking for easy FormMail Script





eday2010
I have a form on my page that people can fill out and send it to me. Right now it is set to relay through someone elses cgi mail script. I searched the forms, and did not find any topic on this.

What I am lokoing for is a simple CGI or PHP script that will let the form be emailed to me. I want to have my own instead of using someone elses. Does any have or know of a simple script to achieve this task and how to get it to work? Anything I have found on Google looks more complicated than necessary. Thanks in advance Very Happy
Bondings
Just make a form and when it's submitted, it should send a mail to you or someone else like this;
Code:
<? mail($email,$subject,$message) ?>

By the way, don't let them fill in the recipient email. Wink
eday2010
My form is in plain HTML. Will that still work, or does my form need to be written in php?
Bondings
Put this in the file where you submit your form to.

Code:
<?
$email = "your-email@something.com";
$subject = $HTTP_POST_VARS['subject'];
$message = $HTTP_POST_VARS['message'];
mail($email,$subject,$message);
?>


Afterwards, rename the file to *something*.php in order for php code to work.
eday2010
I want the form submitted to my email, which it does. This is the beginning of my form that tells it where to send it to and what to do:

Code:

<form action="http://homepage.eircom.net/cgi-bin/auto_mail.cgi" method="post" name="Estimate" id="Estimate">
            <div align="left">
              <input type="hidden" name="TO" value="info@wnstudios.ca" />
              <input type="hidden" name="SUBJECT" value="Project Estimate" />
              <input type="hidden" name="RETURN" value="http://www.wnstudios.ca/sent.html" />



And here is my submit button:

Code:
<a href="javascript:document.Estimate.submit()"><img src="graphics/submit.gif" alt="Submit" width="70" height="24" border="0" /></a>



Now, what I want is to replace the http://homepage.eircom.net/cgi-bin/auto_mail.cgi with my own mail script. Where can I get one so that I don't have to rely on an outside source like I do now? Or is it easier to redo the whole form in php, even though I don't know php, and use some function that php has for that?
smokey4life
This is a very simple yet customizable form 2 e-mail script. Custom Thank You Pages, File Attachment/Upload, Unlimited fields For Form 2 E-mail

Since i cannot upload attachments here ill give you the code:
All you have to do is place this code into a text file, set a couple of variables in the script and your DONE! Make sure to set the ScriptName variable to whatever you named the script!!

Code:
#!/usr/bin/perl
my $script_name              = 'form2email.pl';
my $HTML_thankyou            = 'http://www.your-website-url.co.uk/thankyou.htm';
my $to                       = 'YourEmail@your-website-url.co.uk';
my $from                     = 'YourEmail@your-website-url.co.uk';
my $mailprog                 = '/usr/sbin/sendmail';
my $subject                  = 'Web Enquiry from www.your-website-url.co.uk';
##################################################################################
#
#          That's everything you need to get your script running!
#                You don't need to change anything else
#      unless you want to use any of the advanced features of the script
#
##################################################################################
# Advanced Settings Log details
my $log                      = 0;
my $log_name                 = 'log.txt';
my $seperator                =  '##### log #####';
my $data_only                = 0;
##################################################################################
# Admin mode
my $admin_mode               = 'admin';
my $username                 = "username";
my $password                 = "password";
##################################################################################
# Advanced Settings
my $kill_image_buttons_value = 1;
my $kill_html_tags        = 1;
my $subject_field            = "";
my $max_message_length        = 1000;
my $max_message_error        = "Your message is too big";
my $send_just_data           = 0;
##################################################################################
# Advanced Settings From Field Name
my $from_field_name          = 'Email';
my $from_field_name_error    = "Data Error in $from_field_name";
##################################################################################
# Advanced Settings Auto Responder
my $auto_responder           = 0;
my $auto_responder_from      = 'email@your-website-url.co.uk';
my $auto_responder_message   = "responder.txt";
my $auto_responder_subject   = "Email from your-website-url.co.uk";
##################################################################################
# Advanced Settings Environmental values
my $REMOTE_ADDR              = 1;
my $HTTP_USER_AGENT          = 1;
my $DATE                     = 1;
##################################################################################
# Advanced Settings SMTP email
# use Net::SMTP;
my $send_via_SMTP            = 0;
my $mailhost                 = 'smtp.com';
##################################################################################
# Advanced Settings required fields
my $required_fields_form     = 0;
my @required_fields          = ();
my @required_fields_numbers  = ();
my @required_fields_email    = ();
my $error_fields_require     = "Field is blank, it is required";
my $error_fields_numbers     = "Only numbers";
my $error_fields_email       = "Email address is not valid";
my $error_fields_forbidden   = "Forbidden field name";
my $error_title              = "<b>Sorry, we need you to check the following</b>";
my $fontColor                = "black";
my $fontSize                 = 3;
my $fontFace                 = "Verdana";
my $return_message           = "Please click 'back' on your browser and try again";
##################################################################################
# Advanced Settings extra thank you page
$HTML_thankyou_field_name = 'ThankYouPage';
$ThankYou{'thankyou1'}       = 'http://www.your-website-url.co.uk/';
$ThankYou{'thankyou2'}       = 'http://www.your-website-url.co.uk/';
$ThankYou{'thankyou3'}       = 'http://www.your-website-url.co.uk/';
$ThankYou{'thankyou4'}       = 'http://www.your-website-url.co.uk/';
$ThankYou{'thankyou5'}       = 'http://www.your-website-url.co.uk/';
$ThankYou{'thankyou6'}       = 'http://www.your-website-url.co.uk/';
$ThankYou{'thankyou7'}       = 'http://www.your-website-url.co.uk/';
$ThankYou{'thankyou8'}       = 'http://www.your-website-url.co.uk/';
$ThankYou{'thankyou9'}       = 'http://www.your-website-url.co.uk/';
##################################################################################
# Advanced Settings extra email address
$field_name_email = 'SendToAddress';
$SendTo{'email1'}            = 'email@your-website-url.co.uk';
$SendTo{'email2'}            = 'email@your-website-url.co.uk';
$SendTo{'email3'}            = 'email@your-website-url.co.uk';
$SendTo{'email4'}            = 'email@your-website-url.co.uk';
$SendTo{'email5'}            = 'email@your-website-url.co.uk';
$SendTo{'email6'}            = 'email@your-website-url.co.uk';
$SendTo{'email7'}            = 'email@your-website-url.co.uk';
$SendTo{'email8'}            = 'email@your-website-url.co.uk';
$SendTo{'email9'}            = 'email@your-website-url.co.uk';
##################################################################################
# Advanced Settings file upload
my @file_upload_fields       = ();
my $rename_file              = 0;
my $max_size                 = 100000;
my @required_file_types      = ("txt", "jpg", "jpeg", "tif", "gif");
my $error_max_size           = "Your file is too big!";
my $error_file_type          = "File type is not valid!";
my $file_dir                 = "/path/to/your/directory";
my $file_URL                 = "http://www.your-website-url.co.uk/files";
my $useKb                    = 0;
##################################################################################
#
#          Stop! You don't need to edit anything below this line
#
##################################################################################

use CGI qw/:standard :cgi-lib/;

@date=localtime();
$date[4]++;
$date[5]+=1900;
$date="$date[5]-$date[4]-$date[3]";

%FORM = parse_cgi();

# check required fields param in form if necessary
if ($required_fields_form) {
   my $reqfields = $FORM{required_fields};
   $reqfields =~ s/\s//g;
   @required_fields = ();
   @required_fields = split(/,/,$reqfields); 
   $reqfields = $FORM{required_fields_numbers};
   $reqfields =~ s/\s//g;
   @required_fields_numbers = ();
   @required_fields_numbers = split(/,/,$reqfields); 
   $reqfields = $FORM{required_fields_email};
   $reqfields =~ s/\s//g;
   @required_fields_email = ();
   @required_fields_email = split(/,/,$reqfields); 
}

if($FORM{mode} eq $admin_mode){
   if($FORM{login}){
      if ($FORM{login} eq $username && $FORM{password} eq $password){$FORM{hash}=crypt($password,$username);}
      else{promt();}
   }
   elsif ($FORM{hash} ne crypt($password,$username)){promt()};
   #read log file
   open(F, "$log_name") or error("Can't open log-file");
   local $/;
   my $data = <F>;
   close F;
   $seperator.="\n";
   @data = split($seperator, $data);   
   #delete if act=delete
   if ($FORM{action} eq 'delete'){
      @items =split(", ", $FORM{Item});
      
      for(@items){$Items{$_}=1;}
      #error($Items{1});
      my $i=1;
      my $a=0;
      my @new_data;
      for(@data){
         unless($Items{($i)}){
            $new_data[$a++] = $_ ;
            
         }
         $i++;
      }
      @data=@new_data;
      open (LOG, ">$log_name") or error("Can't open log file");
      print LOG join("$seperator",@data);
      close LOG;
      print "Location: $script_name?mode=$admin_mode&hash=$FORM{hash}\n\n";
      exit;
   }

   my $total = @data;
   my $i=1;
   my $txt = qq~
   <script>
      function deleteItem(){
         myform.submit();
      }
   </script>
   <form name=myform><input type=hidden name=mode value=$admin_mode>
   <input type=hidden name=action value=delete>
   <input type=hidden name=hash value=$FORM{hash}>
   <table width=600><tr><th class=of align=center>Total Emails: $total</th></tr>
   <tr><td class=off align=right><a href=javascript:deleteItem()>delete marked messages</a>&nbsp;</td></tr>~;
   for(@data){
      $_=~s/\n/<br>/g;
      $txt.= "<tr><td class=of>&nbsp;Email #$i</td></tr>";
      $txt.= "<tr><td class=off>$_</td></tr>";
      $txt.= "<tr><td class=off align=right><a href=$script_name?mode=$admin_mode&action=delete&Item=$i&hash=$FORM{hash}>delete</a> <input type=checkbox name=Item value=$i>&nbsp;</td></tr>";
      $i++;
   }
   $txt.="</table></form>";
   
   html_text($txt);

   exit;
}

push @required_fields,$field_name_email unless $to;
push @required_fields_email,$from_field_name if $FORM{$from_field_name};
test_form();
my @to = ();
my $logText = "";
foreach(@field){
   if ($_ eq $from_field_name){
      $from =  $FORM{$from_field_name} if  $FORM{$from_field_name};
      error("$from_field_name_error")  if length($FORM{$from_field_name})>40;
      error("$from_field_name_error")  if $FORM{$from_field_name}=~m/:/s;
      error("$from_field_name_error")  if $FORM{$from_field_name}=~m/Content-type/is;
      error("$from_field_name_error")  if $FORM{$from_field_name}=~m/\n/is;
      $from =~ s/<([^>]|\n)*>//gs;
      $from =~ s/ //gs;
      $from =~ s/\n|\r//gs;
      $message.="$_: " unless $send_just_data;
      $message.="$FORM{$_}\n";
      $logText.="$_: " unless $data_only;
      $logText.="$FORM{$_}\n";
   }
   elsif ($_ eq $subject_field){$subject =  $FORM{$subject_field} if  $FORM{$subject_field};}
   elsif ($_ eq $HTML_thankyou_field_name){$HTML_thankyou =  $ThankYou{$FORM{$HTML_thankyou_field_name}} if  $ThankYou{$FORM{$HTML_thankyou_field_name}};}
   elsif ($_ eq $field_name_email){
      if  ($FORM{$field_name_email}){
         my @mails =  split(", ",$FORM{$field_name_email});
         foreach(@mails){push @to, $SendTo{$_} if $SendTo{$_};}
      }
   }
        elsif ((in_array($_ ,@file_upload_fields)) && ($FORM{$_} ne ""))
        {
     my $fn = save_file($_,$file_dir);
          $message .= "$_ : " unless $send_just_data;
          $message .= "$file_URL/$fn\n";
          $logText .= "$_ : " unless $data_only;
          $logText .= "<a href=\"$file_URL/$fn\">$file_URL/$fn</a>\n";
        }
   else{
           if ( !($kill_image_buttons_value && $_=~/(\.|\A)(x|y)\Z/) ) {
      $message.="$_: " unless $send_just_data;
      $message.="$FORM{$_}\n";
      $logText.="$_: " unless $data_only;
      $logText.="$FORM{$_}\n";
           }
   }

}
push @to, $to if $to && !@to;

my @checker = split(/[\r\n]/, $message);
my $line;
foreach $line(@checker)
{  if (($line =~ /^to:/i) || ($line =~ /^cc:/i) || ($line =~ /^bcc:/i) || ($line =~ /^from:/i) || ($line =~ /^reply-to:/i) || ($line =~ /Content-Type:/i)) {
      error("use of reserved words to:, cc:, bcc: or reply-to: at line \"$line\"<br>");
   }
}

if ($REMOTE_ADDR){
   $message.="REMOTE_ADDR: " unless $send_just_data;
   $message.="$ENV{REMOTE_ADDR}\n";
   $logText.="REMOTE_ADDR: " unless $data_only;
   $logText.="$ENV{REMOTE_ADDR}\n";
}
if ($HTTP_USER_AGENT){
   $message.="HTTP_USER_AGENT: " unless $send_just_data;
   $message.="$ENV{HTTP_USER_AGENT}\n";
   $logText.="HTTP_USER_AGENT: " unless $data_only;
   $logText.="$ENV{HTTP_USER_AGENT}\n";
}
if ($DATE){
   $message.="DATE: " unless $send_just_data;
   $message.="$date[2]:$date[1]:$date[0] $date\n";
   $logText.="DATE: " unless $data_only;
   $logText.="$date[2]:$date[1]:$date[0] $date\n";
}
error($sendToError) unless @to;
error($max_message_error) if length($message)>$max_message_length;

if($log){
   $logText="To: ".join(", ", @to)."\nSubject: $subject\n".$logText;
   $logText="$seperator\n".$logText if -f $log_name;
   open (LOG, ">>$log_name") or error("Can't open log file");
   print LOG $logText;
   close LOG;
}

foreach(@to){
        my $to = $_;
        $to =~ s/\r//g; $from =~ s/\r//g; $subject =~ s/\r//g;
        $to =~ s/\n//g; $from =~ s/\n//g; $subject =~ s/\n//g;
   male("$to", "$from", $subject, $message);
   }
if($auto_responder && $FORM{$from_field_name}){
   $FORM{$from_field_name} =~ s/<([^>]|\n)*>//g;
   $FORM{$from_field_name} =~ s/ //g;
   $FORM{$from_field_name} =~ s/ //gs;
   $FORM{$from_field_name} =~ s/\n|\r//gs;
   open(F, "$auto_responder_message") or error("Can't open message file");
   my @message=<F>;
   close F;
   male("$FORM{$from_field_name}","$auto_responder_from",$auto_responder_subject, join('',@message));
   
   }

print "Location: $HTML_thankyou\n\n";
exit;

sub in_array {
   (my $fieldname, my @uploadfields) = @_;

   my $field;
   foreach $field(@uploadfields)
   {
     if ($field eq $fieldname) {
        return 1;
     }
   }
   return 0;
}

sub error{
   print "Content-type: text/html\n\n";
   print "<html><head><title>Error</title></head><body><br><font color=$fontColor size=$fontSize face=$fontFace>$error_title<br><br>$_[0]<br>";
   print "$return_message" if $_[1];
   print "</font></body></html>";
   exit;

}

sub save_file {
   $file=param($_[0]);

   $file =~m/([^\\\/]*\.\w*\Z)/i;
   $filename=$1;
   $filename=~m/.*\.(\w*\Z)/i;
   $type = $1;
   my $found=0;
   foreach(@required_file_types){$found =1 if lc $_ eq lc $type}   
   error($error_file_type." for type $type") unless $found;
   my $tmp_size =0;
   if($rename_file){
      $filename = $_[0]."_".int(rand(10000)).".".$type;
      while(-e $filename){$filename = $_[0]."_".int(rand(10000)).".".$type;}
   }
   $filename =~ s/\s/_/g;
   open(FILE,">$_[1]/$filename") || error("Can't save file $_[1]/$filename");
   binmode FILE;
   while ($bytesread=read($file,$buffer,1024)) {
      print FILE $buffer;
      $tmp_size+=1024;
      if($max_size && $max_size<$tmp_size){
      close FILE; unlink "$_[1]/$filename";
      error("$error_max_size");
      }
   }
   close(FILE);
        return "$filename";
}

sub parse_cgi{

  my %FORM = Vars;
  @field = param;
  my $a++;
  foreach $key (keys %FORM) {
          $FORM{$key} =~ s/%(..)/pack("c",hex($1))/ge;
          $FORM{$key} =~ s/<!--(.|\n)*-->//g if $kill_html_tags;
          $FORM{$key} =~ s/<([^>]|\n)*>//g if $kill_html_tags;
          $FORM{$key} =~ s/\r//g;
  }
  return %FORM;
}



sub male{

   if($send_via_SMTP){
       $smtp = Net::SMTP->new($mailhost);

       $smtp->mail($_[1]);
       $smtp->to($_[0]);

       $smtp->data();
       $smtp->datasend("To: $_[0]\n");
       $smtp->datasend("From: $_[1]\n");
       $smtp->datasend("Subject: $_[2]\n\n");
       $smtp->datasend("\n");
       $smtp->datasend("$_[3]\n");
       $smtp->dataend();

       $smtp->quit;

   }
   else{
      open(MAIL,"|$mailprog -t");
      print MAIL "To: $_[0]\n";
      print MAIL "From: $_[1]\n";
      print MAIL "Subject: $_[2]\n\n";
      print MAIL "$_[3]\n";
      close(MAIL);
      #print "To: $_[0]<br>";

   }
}

sub test_form{
   my $errors='';
   foreach(@required_fields){
      $errors.="ERROR FIELD &lt; $_ &gt;: $error_fields_require!<br>" if $FORM{$_} eq "";
   }
   foreach(@required_fields_numbers){
      $errors.="ERROR FIELD &lt; $_ &gt;: $error_fields_numbers!<br>" if $FORM{$_}=~m/\D/ or $FORM{$_} eq '';
   }
   foreach(@required_fields_email){
      $errors.="ERROR FIELD &lt; $_ &gt;: $error_fields_email!<br>" if $FORM{$_} !~m/\A\S+?\@\S+?\.\S+?\Z/;
   }                                                                                                                       
        foreach(keys(%FORM)){
           if ( (uc($_) eq uc('to')) || (uc($_) eq uc('cc')) || (uc($_) eq uc('bcc'))|| (uc($_) eq uc('reply-to'))|| (uc($_) eq uc('from'))|| (uc($_) eq uc('Content-Type'))) {
                $errors.="ERROR FIELD &lt; $_ &gt;: $error_fields_forbidden!<br>";
           }
        }       
        foreach (keys(%FORM)){
           if (($FORM{$_} =~ /bcc:/i)||($FORM{$_} =~ /cc:/i)||($FORM{$_} =~ /from:/i)||($FORM{$_} =~ /reply-to:/i)||($FORM{$_} =~ /Content-Type:/i) ||($FORM{$_} =~ /to:/i)) {
                $errors.="ERROR FIELD &lt; $_ &gt;: use of reserved words to:, cc:, bcc: or reply-to:!<br>";
           }
        }
        my $http_user_agent = $ENV{HTTP_USER_AGENT};
        $http_user_agent =~ s/[\s\n]//g;
        if ($http_user_agent eq "") { $errors .= "ERROR : browser problem<br>";}

   error("$errors",1) if $errors;
   
   
return;
}

sub html_text{
   print "Content-type: text/html\n\n" unless $type;
   print qq|<html>
      <head>
      <title>:: Admin Mode</title>
      <style>
         tr,td,body {font-family: Tahoma, Arial; font-size:10pt;} 
         .of {border-style:solid; border-width: 1; border-color : #999999; background-color:#dddddd}
         .on {border-style:none;background-color:#ddeedd}
         .off {border-style:none;background-color:#f3f3f3}
      </style>
      </head>
      <body>
      $_[0]
      </body></html>|;
   exit;

}
sub promt{
       html_text(qq|
         <br><br><br><br><center><form method=post action=$script_name>
         <input type=hidden name=mode value=$admin_mode>
         <table border=0 width=280>
           <tr><th colspan=2 class=of>:: Admin mode</th></tr>
      <tr class=on><td width=43% align=right>Login: </td>
          <td width=57%><input type=text name=login size=13></td></tr>
      <tr class=on><td align=right>Password: </td>
          <td><input type=password name=password size=13></td></tr>
      <tr class=on><td colspan=2 align=center><input type=submit></td></tr>
         </table></form></center>|);
   exit;
}



Heres the code to insert the form into your webpage:

Code:
<form method="POST" action="/cgi-bin/form2email.pl">
Name:<br><input type="text" name="Name" size="60"><br>
Company:<br><input type="text" name="Company" size="60"><br>
Telephone Number:<br><input type="text" name="Telephone" size="60"><br>
Email Address:<br><input type="text" name="emailaddress" size="60"><br>
Your enquiry:<br><textarea rows="5" name="YourEnquiry" cols="60"></textarea><br>
<input type="submit" value=" [ send enquiry ] ">
</form>
Bondings
Ok, let's make it php. I never worked with html-cgi forms so I really can't help you with those.

First of all, never use the email in your form, not even hidden. Otherwise a spammer can easily use that to send a few thousand/millions spam emails. Put your own email in the script.

Here we go:

You forgot to paste the rest of the code, so I can't include them in here.
Code:
<form action="http://homepage.eircom.net/mail-form.php" method="post" name="Estimate" id="Estimate">
            <div align="left">

I removed the first three inputs, they aren't needed. But there needs to be an input field for the subject(if needed) and the message.

Then put in mail-form.php:

Code:
<?
$email = "info@wnstudios.ca";
$subject = $HTTP_POST_VARS['subject'];
$message = $HTTP_POST_VARS['message'];
mail($email,$subject,$message);
?>


This should be enough.

Edit: ok smokey4life's script might have more features, but mine is easier and shorter. Wink
eday2010
2 questions, first one for Smokey:

Where to I put the pearl script? if I put it in the cgi-bin folder, i get an 500 internal server error. Same if I put it in my root directory (while changing the path in the Form Action tag, respectivey).


Bondings:

Can I kep the mail-form.php file on on my server space, so the address isn't http://homepage.eircom.net/mail-form.php, but instead is http://www,wnstudios.ca/mail-form.php? And where do I put it in my files? just in the root, or in the cgi-bin folder?

Sorry if these questions are repetitive.
Bondings
eday2010 wrote:
Bondings:

Can I kep the mail-form.php file on on my server space, so the address isn't http://homepage.eircom.net/mail-form.php, but instead is http://www,wnstudios.ca/mail-form.php? And where do I put it in my files? just in the root, or in the cgi-bin folder?

Sorry if these questions are repetitive.

Sure you can put them on Frihost. I just changed the file name and never looked of the part before it. You should put it in your public_html directory(or a subdirectory of it).
eday2010
OK, I used the php code that Bondings gave me, added a simple html command in it to forward the user to the "sent" page, and uploaded it. It works, but the email I end up getting is blank. None of the fields are in the email, even when they are filled out. No field names, no field entries. How do I fix that?
Bondings
Please post the complete form here so we can take a look at it. Most likely it's just the names of the variables.

To check if the php form is working, go to formmail.php?subject=a_subject&message=a_message
eday2010
Here ya go. And if you want to physically see it, the link is www.wnstudios.ca/estimates.html

Code:
<form action="formmail.php" method="post" name="Estimate" id="Estimate">
            <div align="left">
              <br />
              <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td width="37%"><div align="right" class="style2"><font size="1" face="Arial, Helvetica, sans-serif">Name:</font></div></td>
                  <td width="2%">&nbsp;</td>
                  <td width="61%"><input name="Name" type="text" id="Name5" style="BACKGROUND-COLOR: #DFF2FF; FONT-SIZE: 9; FONT-FACE: Arial; COLOR: #000000" size="20" maxlength="50" /></td>
                </tr>
                <tr>
                  <td><div align="right" class="style2"><font size="1" face="Arial, Helvetica, sans-serif">Company:</font></div></td>
                  <td>&nbsp;</td>
                  <td><input name="Company" type="text" id="Company4" style="BACKGROUND-COLOR: #DFF2FF; FONT-SIZE: 9; FONT-FACE: Arial; COLOR: #000000" size="20" maxlength="50" /></td>
                </tr>
                <tr>
                  <td><div align="right" class="style2"><font size="1" face="Arial, Helvetica, sans-serif">Street Address:</font></div></td>
                  <td>&nbsp;</td>
                  <td><input name="Street Address" type="text" id="Street Address4" style="BACKGROUND-COLOR: #DFF2FF; FONT-SIZE: 9; FONT-FACE: Arial; COLOR: #000000" size="20" maxlength="50" /></td>
                </tr>
                <tr>
                  <td><div align="right" class="style2"><font size="1" face="Arial, Helvetica, sans-serif">
                      <input type="radio" name="Sub Address" value="Apt." />
                    Apt
                    <input name="Sub Address" type="radio" value="Unit" />
                    Unit
                    <input type="radio" name="Sub Address" value="P.O. Box" />
                    P.O. Box:</font></div></td>
                  <td>&nbsp;</td>
                  <td><input name="#" type="text" id="#4" style="BACKGROUND-COLOR: #DFF2FF; FONT-SIZE: 9; FONT-FACE: Arial; COLOR: #000000" size="20" maxlength="10" /></td>
                </tr>
                <tr>
                  <td><div align="right" class="style2"><font size="1" face="Arial, Helvetica, sans-serif">City:</font></div></td>
                  <td>&nbsp;</td>
                  <td><input name="City" type="text" id="City4" style="BACKGROUND-COLOR: #DFF2FF; FONT-SIZE: 9; FONT-FACE: Arial; COLOR: #000000" size="20" maxlength="50" /></td>
                </tr>
                <tr>
                  <td><div align="right" class="style2"><font size="1" face="Arial, Helvetica, sans-serif">Province/State:</font></div></td>
                  <td>&nbsp;</td>
                  <td><input name="Province/State" type="text" id="Province/State4" style="BACKGROUND-COLOR: #DFF2FF; FONT-SIZE: 9; FONT-FACE: Arial; COLOR: #000000" size="20" /></td>
                </tr>
                <tr>
                  <td><div align="right" class="style2"><font size="1" face="Arial, Helvetica, sans-serif">Postal/Zip Code:</font></div></td>
                  <td>&nbsp;</td>
                  <td><input name="Postal/Zip Code" type="text" id="Postal/Zip Code4" size="10" style="BACKGROUND-COLOR: #DFF2FF; FONT-SIZE: 9; FONT-FACE: Arial; COLOR: #000000" /></td>
                </tr>
                <tr>
                  <td valign="top"><div align="right" class="style2"><font size="1" face="Arial, Helvetica, sans-serif">Country:</font></div></td>
                  <td valign="top">&nbsp;</td>
                  <td valign="top"><input name="Country" type="text" id="Country" style="BACKGROUND-COLOR: #DFF2FF; FONT-SIZE: 9; FONT-FACE: Arial; COLOR: #000000" size="20" maxlength="20" /></td>
                </tr>
                <tr>
                  <td valign="middle"><div align="right"><span class="style2"><font size="1" face="Arial, Helvetica, sans-serif">E-Mail:</font></span></div></td>
                  <td valign="top">&nbsp;</td>
                  <td valign="top"><input name="E-Mail" type="text" id="E-Mail4" style="BACKGROUND-COLOR: #DFF2FF; FONT-SIZE: 9; FONT-FACE: Arial; COLOR: #000000" maxlength="100" /></td>
                </tr>
                <tr>
                  <td valign="middle"><div align="right"><span class="style2"><font size="1" face="Arial, Helvetica, sans-serif">Daytime Tel: </font></span></div></td>
                  <td valign="top">&nbsp;</td>
                  <td valign="top"><input name="Day Phone" type="text" id="Day Phone5" style="BACKGROUND-COLOR: #DFF2FF; FONT-SIZE: 9; FONT-FACE: Arial; COLOR: #000000" maxlength="13" /></td>
                </tr>
                <tr>
                  <td valign="middle"><div align="right"><span class="style2"><font size="1" face="Arial, Helvetica, sans-serif">Evening Tel: </font></span></div></td>
                  <td valign="top">&nbsp;</td>
                  <td valign="top"><input name="Evening Phone" type="text" id="Evening Phone4" style="BACKGROUND-COLOR: #DFF2FF; FONT-SIZE: 9; FONT-FACE: Arial; COLOR: #000000" maxlength="13" /></td>
                </tr>
                <tr>
                  <td valign="middle"><div align="right"><span class="style2"><font size="1" face="Arial, Helvetica, sans-serif">Project Type:</font></span></div></td>
                  <td valign="top">&nbsp;</td>
                  <td valign="top"><select name="Project Type" id="select3" style="BACKGROUND-COLOR: #DFF2FF; FONT-SIZE: 9; FONT-FACE: Arial; COLOR: #000000">
                    <option>Select One...</option>
                    <option value="Web Design">Web Design</option>
                    <option value="Photo Touch-Up">Photo Touch-Up</option>
                    <option value="CD-ROM">CD-ROM</option>
                    <option value="CD Covers">CD Covers</option>
                    <option value="Newsletter">Newsletter</option>
                    <option value="Business Card">Business Card</option>
                    <option value="Poster/Notice">Poster/Notice</option>
                    <option value="Corporate Identity">Corporate Identity</option>
                    <option value="Interactive Multimedia">Interactive Multimedia</option>
                    <option value="Multimedia Presentation">Multimedia Presentation</option>
                    <option value="Product Logo">Product Logo</option>
                  </select></td>
                </tr>
                <tr>
                  <td valign="middle"><div align="right"><span class="style2"><font size="2"><font size="2"><font size="1" face="Arial, Helvetica, sans-serif">Other</font></font></font></span></div></td>
                  <td valign="top">&nbsp;</td>
                  <td valign="top"><input name="Project-Other" type="text" id="Project-Other3" style="BACKGROUND-COLOR: #DFF2FF; FONT-SIZE: 9; FONT-FACE: Arial; COLOR: #000000" maxlength="150" /></td>
                </tr>
                <tr>
                  <td valign="middle"><div align="right"><span class="style2"><font size="1" face="Arial, Helvetica, sans-serif">Details</font></span></div></td>
                  <td valign="top">&nbsp;</td>
                  <td valign="top"><textarea name="Details" cols="30" rows="4" wrap="virtual" id="Details" style="BACKGROUND-COLOR: #DFF2FF; FONT-SIZE: 9; FONT-FACE: Arial; COLOR: #000000"></textarea></td>
                </tr>
              </table>
              <br />
              <table width="62%" border="0">
                <tr>
                  <td width="81%" height="36" valign="top"><div align="right"> <a href="javascript:document.Estimate.submit()"><img src="graphics/submit.gif" alt="Submit" width="70" height="24" border="0" /></a> <br />
                  </div></td>
                  <td width="19%" valign="top"><a href="javascript:document.Estimate.reset()"><img src="graphics/reset.gif" alt="Reset" width="65" height="24" border="0" /></a></td>
                </tr>
              </table>
            </div>
         </form>
Bondings
Your forms seems to be a bit longer than I thought (subject and message). My small php script isn't able to handle all that. You most likely need to use a bigger script like the one of smokey4life.
eday2010
Shawg.

Can't I add in the other fields that I have, using the same format you used for the message and subject variables?
Bondings
Yes, that should also be possible. Maybe try something like this:

$message='field1: ';
$message.=$HTTP_POST_VARS['field1'];
$message.='\n\n';

$message.='field2: ';
$message.=$HTTP_POST_VARS['field2'];
$message.='\n\n';


And the field1,2,3,... the names of the input fields.
eday2010
I shall give that a whirl tomorrow and let you know how it turned out. Shawg.
smokey4life
The script itself has to be placed in the cgi-bin of course, and you just add the form to any webpage within the public_html folder. Make sure you set the variables at the top of the script.
eday2010
Shawg... adding the following into the php script did not work:

Code:

$message='field1: ';
$message.=$HTTP_POST_VARS['field1'];
$message.='\n\n';

$message.='field2: ';
$message.=$HTTP_POST_VARS['field2'];
$message.='\n\n';


I still get blank emails. I will try to get Smokey's to work. Anytime I put any formmail script into the cgi-bin folder, I get a 500 Internal Server Error. So I have to leave it in the root directory. Anyone else have any ideas?

That long script from Smokey won't work for me either. I don't know what I am doing wrong, but it won't work in the cgi-bin folder nor in the root directory of my site. It gives me server errors saying I am not permitted to access the pearl file. Booo. Is there no simple script to do this?
Sunny
eday2010 wrote:
Anytime I put any formmail script into the cgi-bin folder, I get a 500 Internal Server Error. So I have to leave it in the root directory. Anyone else have any ideas?



That normally happens when you have wrong permissions set Set the file permission to 755(can be done easily using file manager ) and see if it works.
Bondings
Or just put the cgi file outside the cgi-bin directory. That should also be working, I think.
eday2010
The permissions for the cgi-bin folder is set to 755, as is the public_html directory. I have no problem leaving in the root directory, but I can't get the long script that Smokey gave me to work. Shawg; this is more complicated than I wanted it to be.

I don't have a cgi file though. That is what I am looking for on here. I don't care where I have to put it as long as it works. Even a php or pearl file so the destination email is hidden from surfers, but I can't get any to work right.
Bondings
eday2010 wrote:
Shawg... adding the following into the php script did not work:

Code:

$message='field1: ';
$message.=$HTTP_POST_VARS['field1'];
$message.='\n\n';

$message.='field2: ';
$message.=$HTTP_POST_VARS['field2'];
$message.='\n\n';


I still get blank emails. I will try to get Smokey's to work. Anytime I put any formmail script into the cgi-bin folder, I get a 500 Internal Server Error. So I have to leave it in the root directory. Anyone else have any ideas?

That long script from Smokey won't work for me either. I don't know what I am doing wrong, but it won't work in the cgi-bin folder nor in the root directory of my site. It gives me server errors saying I am not permitted to access the pearl file. Booo. Is there no simple script to do this?

The thing was, you should be renaming the field1, field 2, field 3, .. into the actual names of the input fields.

Code:
<input name="E-Mail"

Like "E-mail" for this one.
eday2010
I know that, and I did that. It didn't work.
smokey4life
Hello again e-day, i see that you created a new topic on this matter and your still having problems and i got your PM as well if you still have problems after following the instructions i sent you in your private message i would be more then happy to set this script up for you. Im allways willing to help others Smile
Daniel15
You posted something similar here: http://frihost.com/forums/vt-19701.html

I replied to that topic with a simple PHP-based script (which I wrote) that puts all of the variables in the form into the email. See that topic for the script.
niranvv
hai,
please have a look at:

http://frihost.com/forums/vt-21009.html

here u can easily setup the files to send online datas to our email address!
I Think, it can help you!

Love,
Niran
www.niran.frih.net


Laughing
Related topics
looking for a script.
CGI FormMail Script Part II
what to use
looking for password gate script
Looking for a rating system script.
Looking for an email/attachment form script
Help to find a script
Script for text area with html support
looking for mobile script
Joomla support?
Wanted: JS/Greasemonkey script...
OK, really easy html script...
Viral Affiliate Networks Script
Teamspeak Integration
Reply to topic    Frihost Forum Index -> Support and Web Hosting -> Web Hosting Support

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.