簡體   English   中英

郵件發送后(wp_mail)如何重定向?

[英]How do i redirect after my mail has been send(wp_mail)?

我想知道如何在發送郵件后重定向,我嘗試使用javascript進行嘗試,還嘗試了header("Location: "www.google.com"")但無法正常工作,而且我不知道如何解決此問題。 我真的希望有人能幫助我。 這是我的代碼:

<script>
        var text;
        function show(param_div_id,button) {    
            <?php
            if(isset($_POST['reset'])) {
                $headers  = "MIME-Version: 1.0" . "\n";
                $headers .= "MIME-Version: 1.0\r\n";
                $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
                $result = str_ireplace("undefined" , "" , $_POST["ll"][0]);
                $email = $_POST["ll"][1];
                wp_mail( "email@hotmail.com", "email","Dear, <br><br>".
                    "From test filled in by " .$email. " this came out: <br><br>".
                    $result. "<br><br> Greetings, <br> website.nl"
                    ,$headers); 
            }
            ?>document.getElementById('main_place').innerHTML = document.getElementById(param_div_id).innerHTML;
            text = text + " " + button;
            var ll=document.getElementById('ll');
            ll.value=text;
            console.log(button)
        }
    </script>
    <?php

}

我真的希望在發送電子郵件后轉到“謝謝”頁面。

輸出開始(包括空格)后,PHP無法修改標頭。 您可以使用javascript重定向頁面。 您可以讓if語句回顯javascript window.location.href='www.stackoverflow.com'

if(isset($_POST['reset'])) {
                $headers  = "MIME-Version: 1.0" . "\n";
                $headers .= "MIME-Version: 1.0\r\n";
                $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
                $result = str_ireplace("undefined" , "" , $_POST["ll"][0]);
                $email = $_POST["ll"][1];
                wp_mail( "email@hotmail.com", "email","Dear, <br><br>".
                    "From test filled in by " .$email. " this came out: <br><br>".
                    $result. "<br><br> Greetings, <br> website.nl"
                    ,$headers);
                echo 'window.location.href="www.stackoverflow.com";';
            }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM