Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2011-02-15
18
Medium Priority
?
550 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 668 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 111

Assisted Solution

by:Ray Paseur
Ray Paseur earned 668 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 664 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

CTAs encourage people to do something specific to show interest in your company, product or service. Keep reading to learn why CTAs should always be thought of as extremely important, albeit small, sections of websites.
Dramatic changes are revolutionizing how we build and use technology. Every company is automating, digitizing, and modernizing operations. We need a better, more connected way to work together as teams so we can harness the insights from our system…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Suggested Courses

926 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