Solved

I need php form processor to send to my email.

Posted on 2009-03-30
11
325 Views
Last Modified: 2013-12-13
Hi.

I don't know much about php coding so I am looking for someone to please write the code that will process the form below and send the data entered to my email address. (just make up a generic)

It would be nice to have each data entered on a separate line and leave one line blank in between.

Subject can be: Contest Submission

Thanks in advance
<form name="form1" method="post" action="">
       <table width="429" border="0" align="center" cellpadding="3" class="body_text">
         <tr>
           <td width="220">Your Name: </td>
           <td width="191"><input name="name" type="text" id="name"></td>
         </tr>
         <tr>
           <td>Company Name:</td>
           <td><input name="company" type="text" id="company"></td>
         </tr>
         <tr>
           <td>Email: </td>
           <td><input name="email" type="text" id="email"></td>
         </tr>
         <tr>
           <td>Phone Number: (xxx-xxx-xxxx)</td>
           <td><input name="phone" type="text" id="phone"></td>
         </tr>
         <tr>
           <td>Do you currently have a website?</td>
           <td>Yes
             <input name="radio" type="radio" id="site_yes" value="site_yes">
             no
             <input type="radio" name="radio" id="site_no" value="site_no"></td>
         </tr>
         <tr>
           <td>Do you currently own a domain name?</td>
           <td>Yes
             <input type="radio" name="radio" id="domain_yes" value="domain_yes">
             no
             <input type="radio" name="radio" id="domain_no" value="domain_no"></td>
         </tr>
         <tr>
           <td>If yes, state address:</td>
           <td><label>
             <input type="text" name="webaddress" id="webaddress">
           </label></td>
         </tr>
         <tr>
           <td colspan="2">Describe your vision for your site:</td>
         </tr>
         <tr>
           <td colspan="2"><textarea name="content" id="content" cols="60" rows="5"></textarea></td>
         </tr>
         <tr>
           <td>&nbsp;</td>
           <td><label>
             <input type="submit" name="submit" id="submit" value="Submit" align="right">
           </label></td>
         </tr>
       </table>
     </form>

Open in new window

0
Comment
Question by:wingcat
11 Comments
 
LVL 20

Expert Comment

by:Gawai
ID: 24026352
0
 

Author Comment

by:wingcat
ID: 24028283
I'm looking for the actual code.
0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 24034651
Please clarify what you expect.  Is it just how to send an email in PHP or is it the complete solution that would "process" that form and email the info?  The latter involves a few steps (e.g. validate form info, provide method in case validation fails, format email body, and send email).  If you need it all you should consider asking for just a step in this question.  All of that work, done properly, is more of a "paid" project than an EE question.
bol
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

Author Comment

by:wingcat
ID: 24034837
Hi,

I just want to form processor code what has no validating whatsoever. Just the php code that will process the form and send me the email with the content of the form.

If the code fails, direct to an error page. I have a few examples that I normally use, but this is a little more complex.
0
 
LVL 50

Accepted Solution

by:
Steve Bink earned 500 total points
ID: 24035066
The first 4 lines are mine.  The rest is from THE VERY FIRST LINK posted by gawai.  Make sure he gets some credit.

I know you're a little new here, but you should realize that experts don't just idly comment on questions.  He pointed you to the right place.  The least you could have done was looked at what was offered...you would have had this done already.

RTFM

http://www.php.net/manual/en/function.mail.php
<?
$msg = '';
foreach ($_POST as $key=>$val) {
  $msg .= "$key: $val\n";
}
$to = "someone@example.com";
$subject = "Contest Submission";
$from = "someonelse@example.com";
$headers = "From: $from";
mail($to,$subject,$msg,$headers);
echo "Mail Sent.";
?>

Open in new window

0
 

Author Comment

by:wingcat
ID: 24035562
I actually checked out gaqai's comments and worked for hours without getting anywhere.

I don't see your code utilizing the radio buttons in the form. Is this an over site or am I not getting something here?
0
 
LVL 50

Expert Comment

by:Steve Bink
ID: 24036233
Lines 3-5 iterate through everything in the $_POST variable and include it in the email in this format:

name: Mi Nam
company: the company
email: email@domain.com
[ and so on... ]

One oversight on your form is that all your radio buttons are named "radio", which means the values of different sets of buttons will overwrite each other.  Because of that, you will only see "domain_yes" or "domain_no", and not the "site_yes" or "site_no" selection...or vice versa, but I'm pretty sure the last one defined is the one that sticks.

Try out the code.  If it doesn't work, or doesn't give you the results you want, come back with any changes/problems and we'll work from there.
0
 
LVL 109

Expert Comment

by:Ray Paseur
ID: 24038523
@wingcat: This is a great place to hire a developer or choose a prepackaged solution.  If you take the "minimum" approach to this problem, hackers will almost certainly find a way to turn your web site into an open relay for spam.  

routinet has answered your question accurately and succinctly but it's only a part of the larger question.  A better way to ask something like this is "Where can I find examples of the best practices for taking form input and transmitting it via email?"

Good luck with it, ~Ray
0
 
LVL 50

Expert Comment

by:Steve Bink
ID: 24041861
In that spirit, the links that have been posted to-date are a great starting place.  It really helps to understand the underlying mechanisms you are dealing with.

Some other good resource will be third-party mailer classes, such as PHPMailer or HTML Mime Mail.  Mailer classes construct emails (including text and HTML) along the protocol standard, allow for easy attachments, etc.  Many are simple to install and use, and greatly reduce the amount of work required of a developer.  

http://phpmailer.codeworxtech.com/
http://www.phpguru.org/static/mime.mail.html
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
What does != "" mean in programming 8 76
Currency in SQL? 2 29
PHP Curl to output a url 7 46
PHP 5.6 and 7.x 4 20
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

791 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