开发者

How to send Div Tag content via email using php form?

I have a div that contains some order info from the online store I'm working on. I'm interested is there a way to send that content via php email form?

This is the email script I'm using: Obviously, the $message variable is what bugs me.

<?php
                            if (isset($_POST['email'])) {
                                $to = "slavishaofficial@gmail.com";
                                $subject = "Ovo je vasa porudzbina";
                                $email = 'viroposetilac@gmail.com';
                                $message = ???div content???;
                                $headers = "From: $email";
                      开发者_JAVA百科          $sent = mail($to, $subject, $message, $headers);
                                if ($sent) {
                                    echo "<script>alert('Uspesno ste prosledili porudzbinu na mail')</script>";
                                } else {
                                    echo "<script>alert('Doslo je do problema prilikom slanja porudzbine')</script>";
                                }
                            }

                            ?> 


you cannot get div content directly from php just like that. you can send from your form with javascript

<div id="content">My Content</div>
<form action="/" method="post" onsubmit="this.divcontent.value = document.getElementById('content').innerHTML;">
    <input type="hidden" name="divcontent" id="divcontent" value="" />
    <input type="submit" value="Submit" />
</form>


$message would contain the $_POST['message'] of the div

like

$message = $_POST['message'];


you can encode it first...

$str=htmlspecialchars("<div>testing the div</div>", ENT_QUOTES);

$message = $str;

then when you need to read ur message decode it and use the following code...

$message =htmlspecialchars_decode($orignal_msg_body);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜