Solved

I need php form processor to send to my email.

Posted on 2009-03-30
11
317 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
 

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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
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 108

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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to dynamically set the form action using jQuery.

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now