خرید بک لینک

Vote count: 1

This is my php code, I am using it to post a contact form from my site to my gmail account. It seems that when it gathers the information, it does not sent it and it keeps the typed information visible on my contact.php page, instead of providing any 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 as $field => $data) {
            if(empty($data)) {
                $errors[] = 'The ' . $fields . ' field is required.';
            }
        }

        if(empty($errors)) {

            $mail = new PHPMailer;

            $mail->isSMTP();
            $mail->SMTPAuth = true;

            $mail->Host = 'smtp.gmail.com';
            $mail->Useame = 'xxxx@gmail.com';
            $mail->Password = 'xxxxxx';
            $mail->SMTPSecure = 'ssl';
            $mail->Port = 465;

            $mail->isHTML();

            $mail->Subject = 'Message from The 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, could not send email. Try again later.';    
            }
        }

    }   
        else {
        $errors[] = 'Something went wrong.';    
    }

    $_SESSION['errors'] = $errors;
    $_SESSION['fields'] = $fields;

    header('Location: contact_form.php');

    ?>

I can also post the other main php document which contains the html form elements, if this helps?

asked 3 mins ago

- - , .

برچسب: نویسنده: استخدام کار تاريخ: دوشنبه 17 اسفند 1394 ساعت: 10:11

صفحه بندی