darphas Posted June 18, 2013 Share Posted June 18, 2013 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 Quote Link to comment https://forums.phpfreaks.com/topic/279328-send-a-div-to-mail/ Share on other sites More sharing options...
ginerjm Posted June 18, 2013 Share Posted June 18, 2013 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? Quote Link to comment https://forums.phpfreaks.com/topic/279328-send-a-div-to-mail/#findComment-1436724 Share on other sites More sharing options...
darphas Posted June 18, 2013 Author Share Posted June 18, 2013 Somethink like this <div class="MyDiv"> <h2>Title</h2> <p>Description</p> <img src="photo/img1.jpg"> </div> a little title with info and sometimes images. Quote Link to comment https://forums.phpfreaks.com/topic/279328-send-a-div-to-mail/#findComment-1436726 Share on other sites More sharing options...
ginerjm Posted June 18, 2013 Share Posted June 18, 2013 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. Quote Link to comment https://forums.phpfreaks.com/topic/279328-send-a-div-to-mail/#findComment-1436728 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.