Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2011-02-15
18
Medium Priority
?
540 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Looking for a new Web Host?

Lunarpages' assortment of hosting products and solutions ensure a perfect fit for anyone looking to get their vision or products to market. Our award winning customer support and 30-day money back guarantee show the pride we take in being the industry's premier MSP.

 
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
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…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

661 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