2017-05-31 46 views
0

形式的作品,我也得到了電子郵件,但是當你點擊提交就不會帶你到感謝頁面,它給了我下面的錯誤信息:PHP形式的郵件重定向網頁不工作

Error 404 - Not Found 

The document you are looking for may have been removed or re-named. 
Please contact the web site owner for further assistance. 

這是形式的代碼:

<section class="contactForm"> 
 
    <h1><strong>Contact Andrea</strong></h1> 
 
    <form action="http://ddion.com/webcert_s17/andreas/DW_FINAL/formmail.php" method="post" name="form1" id="form1"> 
 
    <label for="name">Name:</label> 
 
    <input name="name" type="text" required class="formStyle" id="name" form="form1"> 
 
    <br> 
 
    <label for="email">Email:</label> 
 
    <input name="email" type="email" required class="formStyle" id="email" form="form1"> 
 
    <br> 
 
    <label for="comments">Comments:</label> 
 
    <textarea name="comments" cols="5" required class="formStyle" id="comments" form="form1"></textarea> 
 
    <br> 
 
    <input type="submit" class="formStyle" name="submit" id="submit" value="Submit"> 
 
    
 
    </form> 
 
</section>

這是PHP


<?php 
    $name=addslashes($_POST['name']); 
    $email=addslashes($_POST['email']); 
    $comments=addslashes($_POST['comments']); 

// you can specify which email you want your contact form to be emailed to here 

    $toemail = "[email protected]"; 
    $subject = "from AndreaSimentalPhotogragy.com"; 

    $headers = "MIME-Version: 1.0\n" 
      ."From: \"".$name."\" <".$email.">\n" 
      ."Content-type: text/html; charset=iso-8859-1\n"; 

    $body = "Name: ".$name."<br>\n" 
      ."Email: ".$email."<br>\n" 
      ."Comments:<br>\n" 
      .$comments; 

    if (!ereg("^[a-zA-Z0-9_][email protected][a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$", $email)) 
    { 
    echo "That is not a valid email address. Please return to the" 
      ." previous page and try again."; 
    exit; 
    } 

    mail($toemail, $subject, $body, $headers); 
    echo "Thanks for submitting your comments"; 
?> 

我的thankyou.html位於旁邊的PHP。但不知何故不工作......任何想法爲什麼?

+0

在瀏覽器中打開F12。打開日誌記錄。保持頁面之間的日誌。什麼頁面導航到404導致?什麼是感謝頁面?他們有什麼區別? –

+0

你在哪裏編寫了重定向到感謝頁面的代碼? –

+0

爲什麼你的謝謝文件'.. DW_FINAL/0; URL = thankyou.html'?它不應該只是'... DW_FINAL/thankyou.html'嗎? – styl3r

回答

0

deprecated ereg()功能preg_match()

使用此

preg_match()

+0

這可能是真的,但這不是一個答案。等到你有評論權限。 – Synchro