php
  • html
  • email
  • 2013-02-07 33 views 0 likes 
    0

    用戶這是我的HTML表單發送確認電子郵件給誰填表格

    <form method="post" name="myemailform" action="form-to-email.php"> 
    <p> 
        <label for='name'>Enter Name: </label><br> 
        <input type="text" name="name"> 
    </p> 
    <p> 
        <label for='email'>Enter Email Address:</label><br> 
        <input type="text" name="email"> 
    </p> 
    <p> 
        <label for='message'>Enter Message:</label> <br> 
        <textarea name="message"></textarea> 
    </p> 
    <input type="submit" name='submit' value="submit"> 
    </form> 
    

    這是PHP的郵件代碼拿過數據時,用戶點擊提交

    <?php 
    if(!isset($_POST['submit'])) 
    { 
    
    echo "error; you need to submit the form!"; 
    } 
    $name = $_POST['name']; 
    $visitor_email = $_POST['email']; 
    $message = $_POST['message']; 
    
    //Validate first 
    if(empty($name)||empty($visitor_email)) 
    { 
    echo "Name and email are mandatory!"; 
    exit; 
    } 
    $email_from = '[email protected]';//<== update the email address 
    $email_subject = "New Form submission"; 
    $email_body = "You have received a new message from the user $name.\n". 
    "Here is the message:\n $message". 
    
    $to = "[email protected]";//<== update the email address 
    $headers = "From: $email_from \r\n"; 
    $headers .= "Reply-To: $visitor_email \r\n"; 
    
    mail($to,$email_subject,$email_body,$headers); 
    
    //done. redirect to thank-you page. 
    
    header('Location: thank-you.html'); 
    
    ?> 
    

    這表明沒有錯誤但只是在網頁上降落thank-you.html我檢查了我的電子郵件帳戶但沒有收到郵件

    請幫忙什麼錯了

    +0

    @戴爾thanx,但沒有 – Bandayar

    +0

    有趣的是,正是我想到當我看到你的問題! – Dale

    +0

    當然,在表單提交後(註冊表格會有很多例子),必須有很多通過php發送郵件的教程。只要用谷歌搜索就足夠了。 –

    回答

    0

    您可以實現如下:

    1)在數據庫中創建一個激活字段(默認爲false)。
    2)在登記時,將電子郵件發送
    3)填充一個鏈接的電子郵件,包括...

    a) user unique identifier 
    b) activation to active 
    

    所以它會是這個樣子潛在 [代碼] 歡迎用戶名_。感謝您的註冊,請點擊以下鏈接激活您的帳戶 domain.com/register.php?uid=100 &激活= 1

    4)您註冊腳本試圖搶在ID的用戶。
    5)將激活的字段更新爲true

    還有你有一個新的和活躍的用戶。

    願它能給你一個想法。

    相關問題