doushi3202 2014-12-22 09:40
浏览 7

无法获得表格上班

I've searched through the forums and found a lot of threads on this topic but can't seem to find the correct answer or solution for my problem.

I've got a contact form which I can't seem to get working.

HTML:

<form action="php/index.php" id="contact-form" method="post" name="form">
<div>
 <label>
 <span>Naam: (verplicht)</span>
 <input name="vname" placeholder="Uw naam" type="text" tabindex="1" required>
 </label>
</div>
<div>
 <label>
 <span>Email: (verplicht)</span>
 <input name="vemail"  placeholder="Uw e-mail adres" type="email" tabindex="2" required>
</label>
</div>
<div>
<label>
<span>Telefoon:</span>
<input name="vphone" placeholder="Telefoon nummer" type="tel" tabindex="3">
</label>
</div>
<div>
<label>
<span>Bericht: (verplicht)</span>
<textarea name="msg" placeholder="Uw vraag of opmerking" tabindex="4" required></textarea>
</label>
</div>
<div>
<input id="send" name="submit" type="submit" value="VERZENDEN">
</div>
</form>
<!-- /Form -->

And here is the PHP code, I replaced my e-mail adress in the form with MY EMAIL for obvious reasons.

 <?php 

if(isset($_POST['submit'])) {
    $name = $_POST['vname']; 
    $remark = $_POST['msg']; 
    $from_add = $_POST['vemail']; 
    $to_add = "MY EMAIL"; 
    $subject = "Your Subject Name";
    $phone = $_POST['vphone'];
    $headers = 'From: $from_add';

    if ($phone != null){
        $message = "Naam:$name 
 Opmerking: $remark 
 mijn telefoon nummer is $phone";
        mail($to_add,$subject,$message,$headers);
    }else{
        $message = "Naam:$name 
 Opmerking: $remark";
        mail($to_add,$subject,$message,$headers);
    }   
}
?>

Ow I am using XAMPP to run a localhost, perhaps that could be the problem but I'm not sure.

  • 写回答

2条回答 默认 最新

  • doumeikuan6834 2014-12-22 10:14
    关注

    I had that same problem with a horrible server which doesn't send emails.

    So I used a code that connects to a gmail account and sends the email from there.

    try this tutorial: http://coded-words.tumblr.com/post/6936532107/configure-gmail-as-smtp-in-xampp-to-send-mail

    Edit 23.12.2014:

    Do you have something like this in your code?

     <?php
    
        $message = "The mail message was sent with the following mail";
        $headers = "From: youremail@gmail.com";
        mail("youremail@gmail.com", "Testing", $message, $headers);
    
    ?>
    

    (source: http://jiansenlu.blogspot.co.il/2014/10/php-mail-function-using-gmail-account.html)

    If you do have this code:

    Try submitting a different email address than the one you used in your code. Sometimes it goes to the "Sent mail" in your Gmail account without actually showing you that you received a new email. (So you can check your "Sent mail" to see if there is anything over there).

    评论

报告相同问题?