I created a button and want to send an email (onclick)

louverhiannon

New Member
Hello,
Me again :)
i created a button and i want te send an email when i click on it.

i put this php code but it doesnt work

$db =& JFactory::getDBO();

$query = "SELECT id FROM com_deals WHERE email = '" . $_POST["email"] . "'";
$db->setQuery($query);
$db->query();


$result = mysql_query($query) or die(mysql_error());
$data = mysql_fetch_assoc($result);
$entry = mysql_num_rows($result);
//Check if entry exists
if($entry !== 0){
$message = $data['email'];
$to = "dorothee.prevot@gmail.com" ;
$from = "dorothee";
$Subject = "Subject";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-885n-l\r\n";
$headers .= "From: $from\r\n";

if(mail($to, $from, $subject, $message, $headers)){
echo 'Email sent';
}else{
echo 'Failed sending email';
}
}else{
echo 'No email entry found';
}


can somebody help me ?
thanks a lot
 
Thanks for your reply
Yes i know there is a email plugin but my problem is that i want to send the email when i want to "activate" something.
thats why i was using the php plugin
but i dont understand how i can send an email to the field "email".

i tried this code and it works (below) but what i dont understand is how to connect the field in the database to this code.
$to = "dorothee.prevot@gmail.com";
$subject = "This is subject";
$message = "This is simple text message.";
$header = "From:abc@somedomain.com \r\n";
$retval = mail ($to,$subject,$message,$header);
if( $retval == true )
{
echo "Message sent successfully...";
}
else
{
echo "Message could not be sent...";
}
 
I also tried to use the plugin update_col works great but there is one problem for me.
i "need" to have an static email + my placeholder... T_T
Dont know how to do that either...
 
This is php list plugin?
fabrikar.com/forums/index.php?wiki/php-list-plugin

update_col: I don't know if placeholders in email are supported (I think they aren't).
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top