forms - My php code is not working, and as a new php coder I am not sure where my mistake is? -


this php code, using post contact form site gmail account. seems when gathers information, not sent , keeps typed information visible on contact.php page, instead of providing error

 <?php       session_start();      require_once 'phpmailer/phpmailerautoload.php';      $errors = array();      if(isset($_post['name'], $_post['email'], $_post['phonenumber'], $_post['services'], $_post['message_area'])) {          $fields = array(             'name' => $_post['name'],             'email' => $_post['email'],             'phonenumber' => $_post['phonenumber'],             'services' => $_post['services'],             'message_area' => $_post['message_area']         );          foreach($fields $field => $data) {             if(empty($data)) {                 $errors[] = 'the ' . $fields . ' field required.';             }         }          if(empty($errors)) {              $mail = new phpmailer;              $mail->issmtp();             $mail->smtpauth = true;              $mail->host = 'smtp.gmail.com';             $mail->username = 'xxxx@gmail.com';             $mail->password = 'xxxxxx';             $mail->smtpsecure = 'ssl';             $mail->port = 465;              $mail->ishtml();              $mail->subject = 'message rejuviner';             $mail->body = 'from: <br /> name: ' . $fields['name'] . '<br /> email:' . $fields['email'] . '<br /> phone number:' . $fields['phonenumber'] . '<br /> services:' . $fields['services'] . '<br /> <p>' . $fields['message_area'] . '</p>';              $mail->fromname = 'contact';              $mail->addreplyto($fields['email'], $fields['name']);              $mail->addaddress('lilidinova@gmail.com', 'lily kostadinova');              if($mail->send()) {                 header('location: thanks.php');                 die();             }             else {                 $errors[] = 'sorry, not send email. try again later.';                 }         }      }            else {         $errors[] = 'something went wrong.';         }      $_session['errors'] = $errors;     $_session['fields'] = $fields;      header('location: contact_form.php');      ?> 

i can post other main php document contains html form elements, if helps?


Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -