Jump to content

Send a Div to Mail


darphas

Recommended Posts

I'm making a system and i want to add a button that if you click it.. will send some info from a div to a friend, but to be honest i dont have any idea how can i do this..

 

i used google to find info and i think is something like that can works

<?php
if (isset($_POST['email'])) {
$to = "friendemail";
$subject = "Website Info";
$email = 'email';
$message = ???div content???;
$headers = "From: $email";
$sent = mail($to, $subject, $message, $headers);
if ($sent) {
echo "<script>alert('Email has been sent')</script>";
} else {
echo "<script>alert('Sorry Cannot send this email')</script>";
}
}
?>

the div sometimes contains images so i think this can help 

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

Please help. x.x

Link to comment
https://forums.phpfreaks.com/topic/279328-send-a-div-to-mail/
Share on other sites

You're mixing client side code with server side code.  No Can Do.

 

If you want your php to grab the contents of the div, you need to get it into your $_POST array somehow. (or $_GET.)  Since a div is not an input field you need to change your html to make it so, which sounds silly.  What exactly is in this div that you want to "send" to someone?

Link to comment
https://forums.phpfreaks.com/topic/279328-send-a-div-to-mail/#findComment-1436724
Share on other sites

I'm assuming that the Title and Description change with the image.  You need to hide them in input tags along with the image name when you send the output to the client and then grab them in your php from the POST array upon Submit and pass the text vars to your email and attach the image file to the email.  Not familiar with sending images in email myself, so I can't offer anything more.

Link to comment
https://forums.phpfreaks.com/topic/279328-send-a-div-to-mail/#findComment-1436728
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.