Solved

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

Posted on 2011-02-15
18
530 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
ID: 34900773
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
ID: 34901058
It will be emailed to me via default or to other people within the pull down menu.
0
 

Author Comment

by:libertyforall2
ID: 34901076
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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 2

Expert Comment

by:TimBare
ID: 34901124
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 109

Assisted Solution

by:Ray Paseur
Ray Paseur earned 167 total points
ID: 34919814
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
ID: 34919890
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
ID: 34919901
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
ID: 34919994
>> 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
 

Author Comment

by:libertyforall2
ID: 34920127
"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
ID: 34920194
>> 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
ID: 34920559
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
ID: 34922958
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
ID: 34923179
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
ID: 34923221
So PHP is not installed.  You'll have to use a perl script.
0
 

Author Closing Comment

by:libertyforall2
ID: 34923342
I need help on this
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 34923867
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

The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Html Newline 7 21
really easy css change help please 4 19
I need help changing the colour of this image rollover please? 3 14
PowerShell logging 1 16
FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

828 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