HATA!

0 Cevap php

Ben sadece DreamTemplate.com bir web sitesi şablonu satın ve çevrimiçi ondan bir sınama e-posta göndermek için denedim ve yerine gönderme e-posta sadece söyleyerek kırmızı metin ile çıkageldi: "HATA".

I am not very familiar with PHP, but I can understand the syntax. The code is below:


Contact.html

<script type="text/javascript">
    // <![CDATA[
    jQuery(document).ready(function () {
        $('#contactform').submit(function () {
            var action = $(this).attr('action');
            $.post(action, {
                name: $('#name').val(),
                email: $('#email').val(),
                company: $('#company').val(),
                subject: $('#subject').val(),
                message: $('#message').val()
            }, function (data) {
                $('#contactform #submit').attr('disabled', '');
                $('.response').remove();
                $('#contactform').before('<p class="response">' + data + '</p>');
                $('.response').slideDown();
                if (data == 'Message sent!') $('#contactform').slideUp();
            });
            return false;
        });
    });
    // ]]>
</script>


Contact.PHP

<?php

if(!$_POST) exit;

$email = $_POST['email'];


//$error[] = preg_match('/\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/i', $_POST['email']) ? '' : 'INVALID EMAIL ADDRESS';
if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$email )){
    $error.="You've entered an invalid e-mail address.";
    $errors=1;
}
if($errors==1) echo $error;
else{
    $values = array ('name','email','message');
    $required = array('name','email','message');

    $your_email = "enquiries@ourdomain.com";
    $email_subject = "New Message: ".$_POST['subject'];
    $email_content = "new message:\n";

    foreach($values as $key => $value){
      if(in_array($value,$required)){
        if ($key != 'subject' && $key != 'company') {
          if( empty($_POST[$value]) ) { echo 'PLEASE FILL IN REQUIRED FIELDS'; exit; }
        }
        $email_content .= $value.': '.$_POST[$value]."\n";
      }
    }

    if(@mail($your_email,$email_subject,$email_content)) {
        echo 'Message sent!'; 
    } else {
        echo 'ERROR!';
    }
}
?>

Birisi lütfen yardım edebilir? Ben bu işe neden hiçbir fikrim yok. Tüm herhangi bir yardım çok takdir.

Teşekkür ederim


Update: As advised, I have removed the @ symbol before 'mail'. It is now displaying useful error messages:

"Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in E:\web\autoopti\contact.php on line 31 ERROR!"

0 Cevap