Solved

web forms without ads for contact information in html and/or cgi

Posted on 2011-02-15
18
528 Views
Last Modified: 2013-12-25
I have been working with some templates but am having no success. I need  simple web form that I can embed within a cgi file. The form would have a default contact with a pull down tab that allows to specify which person the user wishes to contact. Ideally, it would include some type of checking to prevent spam. Please help!!
0
Comment
Question by:libertyforall2
  • 8
  • 4
  • 2
  • +2
18 Comments
 
LVL 2

Accepted Solution

by:
TimBare earned 167 total points
Comment Utility
what is this form going to do w/ the information? (email, store in a db, etc...)?

or, do you just want the code for the form itself, with a drop down for names, and some other text fields?
0
 

Author Comment

by:libertyforall2
Comment Utility
It will be emailed to me via default or to other people within the pull down menu.
0
 

Author Comment

by:libertyforall2
Comment Utility
When the form is filled out at submitted, it will be sent to the email of the default or person specified within the pull down tab. It is a basic contact form regarding any thing on the website and can be a simple for that has person, subject, & body. The only other issue is that is should check somehow to make sure it is not a robot but a real person.
0
 
LVL 2

Expert Comment

by:TimBare
Comment Utility
I'm not a CGI guy (i prefer PHP), so we'll have to wait for someone else to chime in for CGI code to do the email function.

As for the check, you'll need a captcha (the scrambled letters in a box that the user will have to type in order for the form to be submitted). You may check in to ReCaptcha.

Sorry I can't be more help w/ the email part.
0
 
LVL 108

Assisted Solution

by:Ray Paseur
Ray Paseur earned 167 total points
Comment Utility
I can give you a sample in PHP.  Perhaps someone else can translate to your preferred scripting language.  Just a thought... PHP is free, open source and very easy to use.  About 14,000,000 sites use it now.  Best of luck with your project, ~Ray
<?php // RAY_form_to_email.php
error_reporting(E_ALL);

// SEND MAIL FROM A FORM

// A FUNCTION TO CLEAN UP THE DATA - AVOID BECOMING AN OPEN-RELAY FOR SPAM
function clean_string($str)
{
    $str = stripslashes($str);
    $str = trim(preg_replace("/ +/", " ", $str));
    $str = preg_replace('/^ a-zA-Z0-9&+:?_\.\-/', '', $str);
    return $str;
}

// REQUIRED VALUES ARE PREPOPULATED - CHANGE THESE FOR YOUR WORK
$from  = "NoReply@Your.org";
$subj  = "Contact Form";

// THIS IS AN ARRAY OF RECIPIENTS
$to[]  = "You@Your.org";
$to[]  = "Her@Your.org";
$to[]  = "Him@Your.org";

// IF THE DATA HAS BEEN POSTED
if (!empty($_POST['email']))
{
    // CLEAN UP THE POTENTIALLY BAD AND DANGEROUS DATA
    $email      = clean_string($_POST["email"]);
    $name       = clean_string($_POST["name"]);
    $telephone  = clean_string($_POST["telephone"]);

    // CONSTRUCT THE MESSAGE
    $content    = '';
    $content   .= "You have a New Query From $name" . PHP_EOL . PHP_EOL;
    $content   .= "Tel No: $telephone" . PHP_EOL;
    $content   .= "Email: $email" . PHP_EOL;

    // SEND MAIL TO EACH RECIPIENT
    foreach ($to as $recipient)
    {
        if (!mail( $recipient, $subj, $content, "From: $from\r\n"))
        {
            echo "MAIL FAILED FOR $recipient";
        }
        else
        {
            echo "MAIL WORKED FOR $recipient";
        }
    }
} // END OF PHP - PUT UP THE FORM
?>
<form method="post">
<br/>Email: <input name="email" />
<br/>Phone: <input name="telephone" />
<br/>Name:  <input name="name" />
<br/><input type="submit" />
</form>

Open in new window

0
 

Author Comment

by:libertyforall2
Comment Utility
Could this php script be embedded within a cgi file? Its fine it there is a seperate php file that needs to be accessed in order to use the information. My main concern is to be able to have the form within an existing webpage ending in index.cgi
0
 

Author Comment

by:libertyforall2
Comment Utility
Also, does the php script above incorporate some type of catptcha? If not, could you modify it to do so?
0
 
LVL 70

Assisted Solution

by:Jason C. Levine
Jason C. Levine earned 166 total points
Comment Utility
>> Could this php script be embedded within a cgi file?

A PHP file works the same way as a CGI file.  You could run the PHP as a separate page.  Instead of:

<form action="/path/to/perl/script.cgi">

You just do

<form action="/path/to/php/script.php">

The handling of the posted data is nearly identical.  You don't need to have the action of the form in the index.cgi file.  So long as your server runs PHP, you can just edit the echo commands that output the form tag and modify it as needed.

>> Also, does the php script above incorporate some type of catptcha? If not, could you modify it to do so?

No, it does not and yes, you can easily modify it.  I would sign up for reCaptcha and then you follow their instructions to modify the script.  Really easy to do...
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

Author Comment

by:libertyforall2
Comment Utility
"A PHP file works the same way as a CGI file.  You could run the PHP as a separate page.  Instead of:

<form action="/path/to/perl/script.cgi">

You just do

<form action="/path/to/php/script.php">"

          Are you saying that I would create a seperate php file with the code above and then within the index.cgi file write a line of code that says <form action="/path/to/php/script.php">?


0
 
LVL 70

Expert Comment

by:Jason C. Levine
Comment Utility
>> Are you saying that I would create a seperate php file with the code above and then within the index.cgi file write a line of code that says <form action="/path/to/php/script.php">?

Assuming your server supports PHP, yes that is mostly correct.  It's a little oversimplified as I am also assuming (based on your question) that you already have the HTML code for the form in the index.cgi file.  My instructions above assume that there is a form tag already present and you just change the action attribute to point to a php file.
0
 

Author Comment

by:libertyforall2
Comment Utility
Turns out this web page is actually an htm though most others are cgi. I have included the code along with the line

<form action="/path/to/php/script.php"> modified to reflect the actual path and name. I have copied the script and place the php file on my server. Nothing seems to appear. How do I know if php is supported?
0
 
LVL 70

Expert Comment

by:Jason C. Levine
Comment Utility
Create a new page called info.php

In that page put the following line and nothing else:

<?php phpinfo(); ?>

Load the page on the server and call it in the browser.  If it returns information, PHP is configured.  If not, it isn't.
0
 

Author Comment

by:libertyforall2
Comment Utility
I added a page called info.php and when I typed in the url only the actual line script appeared <?php phpinfo(); ?>

See the link below

http://mkwc.ifa.hawaii.edu/vmap/info.php
0
 
LVL 70

Expert Comment

by:Jason C. Levine
Comment Utility
So PHP is not installed.  You'll have to use a perl script.
0
 

Author Closing Comment

by:libertyforall2
Comment Utility
I need help on this
0
 
LVL 75

Expert Comment

by:Michel Plungjan
Comment Utility
So why did you accept as answers?

We can try to continue...

Did you try this one?

http://www.boutell.com/email/
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
I've been asked to discuss some of the UX activities that I'm using with my team. Here I will share some details about how we approach UX projects.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now