Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

I need php form processor to send to my email.

Posted on 2009-03-30
11
Medium Priority
?
334 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
[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
11 Comments
 

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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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 51

Accepted Solution

by:
Steve Bink earned 2000 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 51

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 111

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 51

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

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

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.
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
The viewer will learn how to dynamically set the form action using jQuery.
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…
Suggested Courses

604 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