Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 338
  • Last Modified:

I need php form processor to send to my email.

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
wingcat
Asked:
wingcat
1 Solution
 
wingcatAuthor Commented:
I'm looking for the actual code.
0
 
b0lsc0ttCommented:
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.

 
wingcatAuthor Commented:
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
 
Steve BinkCommented:
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
 
wingcatAuthor Commented:
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
 
Steve BinkCommented:
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
 
Ray PaseurCommented:
@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
 
Steve BinkCommented:
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

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.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now