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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.