php - Contact Form Security and Functions Don't Work -


i working on contact form , code doesn't seem work. don't verifications when submitted, don't see user submitted, , form has no security @ all. here produced far, has of things complete, can't work way want. can me this:


edit: making contact form collect inputs childcare website (i need name of parent, email, phone number, , information child). expect to, when submitted visitor/parent, send me verification form submitted , copy of submitted me. parent submitted form should verification form submitted. when form inputted, page resets , don't copy of inputs nor parent verification.. – suppahman 4 mins ago edit

i expecting send me verification of form being submitted, copy of inputs can contact them later, parent gets verification got it, , form should secured nobody can spam me. @ moment, form basically... well... dead. guys able me chance? don't know if answered questions correctly, think should do?


php

$contactname  = $_post["contact-name"]; $contactemail = $_post["contact-email"]; $contactphone = $_post["contact-phone"]; $child_info   = $_post["child_info"]; $to           = 'maemail@gmail.com'; $subject      = 'contact form submission!';  //******************************************************************************************************************************//  if(isset($_post['email'])) {     $to      = "maemail@gmail.com";     $subject = "contact form submission";      function died($error)     {         echo "we sorry, there error(s) found form submitted. ";         echo "these errors appear below.<br /><br />";         echo $error . "<br /><br />";         echo "please go , fix these errors.<br /><br />";         die();     }      if(!isset($_post['contact-name']) || !isset($_post['contact-email']) || !isset($_post['contact-phone']) || !isset($_post['child-info'])) {         died('we sorry, there appears problem form submitted.');     }      $contactname   = $_post['contact-name']; //required     $contactemail  = $_post['contact-email']; //required     $contactphone  = $_post['contact-phone']; //required     $child_info    = $_post['child_info']; //required     $error_message = "";      $email_exp = '/^[a-za-z0-9._%-]+@[a-za-z0-9.-]+\.[a-za-z]{2,4}$/';      if(!preg_match($email_exp, $contactemail)) {         $error_message .= 'the email address entered not appear valid.<br />';     }      $string_exp = "/^[a-za-z .'-]+$/";     $numb_exp   = '/^[0-9.-]';      if(!preg_match($string_exp, $contactname)) {         $error_message .= 'the first name entered not appear valid.<br />';     }      if(!preg_match($numb_exp, $contactphone)) {         $error_message .= 'the phone number entered not appear valid.<br />';     }      if(strlen($child_info) < 2) {         $error_message .= 'the comments entered not appear valid.<br />';     }      if(strlen($error_message) > 0) {         died($error_message);     }      $email_message = "form details below.\n\n";      function clean_string($string)     {         $bad = array(             "content-type",             "bcc:",             "to:",             "cc:",             "href"         );         return str_replace($bad, "", $string);     }      $email_message .= "first name: " . clean_string($contactname) . "\n";     $email_message .= "email: " . clean_string($contactemail) . "\n";     $email_message .= "telephone: " . clean_string($contactphone) . "\n";     $email_message .= "child information: " . clean_string($child_info) . "\n";      $headers = 'from: ' . $contactemail . "\r\n" . 'reply-to: ' . $contactemail . "\r\n" . 'x-mailer: php/' . phpversion();      @mail($to, $subject, $email_message, $headers);     echo "thank contacting us. in touch soon."; } //******************************************************************************************************************************//  $v1      = "                 <html> <body> <style>                     h1 {color:#000066;}                     table {border:1px solid black; background: #e3f0ff;}                 </style> <h1>hello, form has been submitted!</h1> <img src= 'logo1.png' /> <table rules='all' style='border-color: #ffb300;' cellpadding='10' width='500px'> <tr style='background: #ffb300;'><td>first name: $contactname</td> <tr style='background: #fafafa;'><td>email: $contactemail</td> <tr style='background: #fafafa;'><td>phone: $contactphone</td><tr style='background: #fafafa;'><td>child information: $child_info</td></table> </body> </html> "; $message = $v1; $headers = "from: $from\r\n"; $headers .= "content-type: text/html\r\n"; mail($to, $subject, $message, $headers); echo "message has been sent..."; //page re direct  echo $v1; //******************************************************************************************************************************//  $contactname     = $_post["contact-name"]; $contactemail    = $_post["contact-email"]; $contactphone    = $_post["contact-phone"]; $child_info      = $_post["child_info"]; $verificationmsg = 'thank inquiry, contact shortly! <br>best,<br>me<br>©hi logo went here(tm) rights reserved 2015'; $subject         = 'message confirmed!'; $v1              = "                 <html> <body> <style>                     #disclosure {font-size: 8px; color: #333;}                     h1 {color:#000066;}                     table {border:1px solid black;}                 </style> <img src= 'logo1.png' /> <table rules='all' style='border-color: #ffb300;' cellpadding='10' width='500px'> <tr style='background: #ffb300;'><td>email confirmation <tr style='background: #fafafa;'><td>hello  $contactname, message has been recieved! contact shortly! <br><br>best, <br>m<br>©m(tm) rights reserved 2015 </div> </table> </body> </html> "; $headers         = "from: $from\r\n"; $headers .= "content-type: text/html\r\n"; mail($contactemail, $subject, $verificationmsg, $headers);  $count = count(file("formsubmissions.csv")); $today = date("d m y h:i a"); echo $today; echo $v1;  $cvsdata = "\n" . $count . "," . $today . "," . $contactname . "," . $contactemail . "," . $contactphone . "," . $child_info;  $fp = fopen("formsubmissions.csv", "a"); if($fp) {     fwrite($fp, $cvsdata);     fclose($fp); } 

html

<form action="contact.php" class="footer-form" method="post">     <p class="title">how can of service?</p>      <div class="form-group">         <strong>             <input type="text" class="form-control" name="contact-name" id="contact-name" placeholder="name:">         </strong>     </div>     <div class="form-group">         <strong>             <input type="email" class="form-control" name="contact-email" id="contact-email" placeholder="e-mail:">         </strong>     </div>     <div class="form-group">         <strong>             <input type="phone" class="form-control" name="contact-phone" id="contact-phone" placeholder="phone:">         </strong>     </div>     <div class="form-group">         <strong>              <input type="text" class="form-control" name="child_info" id="child_info" placeholder="tell child:">         </strong>     </div>     <button type="submit" class="btn btn-default waves-effect waves-button waves-float waves-classic"><strong>submit</strong></button> </form> 


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -