php - PHPMailer Feedback Email -


i've made form potential clients fill in estimated quote via email. receive emails fine , works way want to.

i have jquery validation, won't bother posting code snippet unless wants see well. echoes possible errors in slidedown div box.

my main concern is, secure? when got form work correctly wanted make sure had done right, did find out header injections etc. i'm quite paranoid right now. not want spam being sent stupid mistakes.

my question is, missing important security features , there way shorten code (listing variables, i'm sure need checked, can checked when they're given variable name?)

the code follows:

<?php error_reporting(0); $emailaddress       = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; $csite          = $_get['csite']; $locate             = $_get['locate']; $describe           = $_get['describe']; $competition        = $_get['competition']; $ideas          = $_get['ideas']; $require            = $_get['require']; $target             = $_get['target']; $time               = $_get['time']; $budget             = $_get['budget']; $look               = $_get['look']; $example            = $_get['example']; $font               = $_get['font']; $photos             = $_get['photos']; $pnum               = $_get['pnum']; $cms                = $_get['cms']; $hosting            = $_get['hosting']; $domain             = $_get['domain']; $features           = $_get['features']; $extra          = $_get['extra']; $hear               = $_get['hear'];  require "assets/class.phpmailer.php"; session_start();  $err = array(); if(!checklen('name'))$err[]='the name field short or empty!';                     if(!checklen('email'))$err[]='the email field short or empty!'; else              if(!checkemail($_post['email']))$err[]='your email not valid!';                       if(!checklen('phone'))$err[]='you have not selected phone!';                           if(md5($_post['verify']) != $_session['verify'])$err[]='the captcha code wrong!';      if(count($err)){ foreach($err $one_er){ echo $one_er . "<br/>";  } exit(); } else session_destroy(); //style how received email $msg='you have been contacted '.$_post['name'].'<br /><br />  <table style="padding:0;margin: 0;padding: 3px;width: 100%;border: 1px solid #000000;border-collapse: collapse;border-spacing: 0;"> <tr>  <td style="width:35%;background:#1775ca;color:#fff;padding:3px;">question</td> <td style="width:65%;background:#1775ca;color:#fff;padding:3px;">answer</td> </tr> <tr> <td>name</td><td>'.$_post['name'].'</td> </tr> <tr> <td>email:</td><td>'.$_post['email'].'</td> </tr> <tr> <td>phone</td><td>'.$_post['phone'].'</td> </tr> <tr> <td>current website</td><td>'.$_post['csite'].'</td> </tr> <tr> <td>location</td><td>'.$_post['locate'].'</td> </tr> <tr> <td>company description</td><td>'.$_post['describe'].'</td> </tr> <tr> <td>competition</td><td>'.$_post['competition'].'</td> </tr> <tr> <td>ideas</td><td>'.$_post['ideas'].'</td> </tr> <tr> <td>requirements</td><td>'.$_post['require'].'</td> </tr> <tr> <td>target audience:</td><td>'.$_post['target'].'</td> </tr> <tr> <td>time frame</td><td>'.$_post['time'].'</td> </tr> <tr> <td>budget</td><td>'.$_post['budget'].'</td> </tr> <tr> <td>desired look</td><td>'.$_post['look'].'</td> </tr> <tr> <td>examples of inspiration</td><td>'.$_post['example'].'</td> </tr> <tr> <td>fonts/colours</td><td>'.$_post['font'].'</td> </tr> <tr> <td>images</td><td>'.$_post['photos'].'</td> </tr> <tr> <td>number of pages</td><td>'.$_post['pnum'].'</td> </tr> <tr> <td>cms</td><td>'.$_post['cms'].'</td> </tr> <tr> <td>hosting</td><td>'.$_post['hosting'].'</td> </tr> <tr> <td>domain</td><td>'.$_post['domain'].'</td> </tr> <tr> <td>features</td><td>'.$_post['features'].'</td> </tr> <tr> <td>extra</td><td>'.$_post['extra'].'</td> </tr> <tr> <td>origin</td><td>'.$_post['hear'].'</td> </tr> </table>  can contact '.$_post['name'].' via email '.$_post['email'].' <br /> recorded ip '.$_server['remote_addr'].'; '; $mail = new phpmailer(); $mail->ismail(); $mail->addreplyto($_post['email'], $_post['name']); $mail->addaddress($emailaddress); $mail->setfrom($_post['email'], $_post['name']); $mail->subject = "you've been contacted contacted ".$_post['name'].""; $mail->msghtml($msg); $mail->send(); unset($_session['post']); echo "message sent!";  // check field length function checklen($str,$len=3){ return isset($_post[$str]) && mb_strlen(strip_tags($_post[$str]),"utf-8") > $len; } // check email validation function checkemail($str){ return preg_match("/^[\.a-z0-9_\-\+]+[@][a-z0-9_\-]+([.][a-z0-9_\-]+)+[a-z]{1,4}$/", $str); } ?> 

i've looked throughout stackoverflow, there's lot on phpmailer, not working - mines working, need eye , better understanding either reassure me it's fine or let me know can improved perhaps!

thank in advance guys!


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -