Jason
asked on
Emailing page
<?php mail(MAIL_ADDRESS, MAIL_SUBJECT, $content, $headers);?>
When this code is put on the page it automatically send the page.
<a href="" onclick= <?php mail(MAIL_ADDRESS, MAIL_SUBJECT, $content, $headers);?> >Email</a>
I was trying to put in a <a> so when the user clicks onto email it is sent.
not automatically
Any advise
When this code is put on the page it automatically send the page.
<a href="" onclick= <?php mail(MAIL_ADDRESS, MAIL_SUBJECT, $content, $headers);?> >Email</a>
I was trying to put in a <a> so when the user clicks onto email it is sent.
not automatically
Any advise
U may try this
send_mail.php
-------------------
<script language="javascript">
function SendMail() {
<?php mail(MAIL_ADDRESS, MAIL_SUBJECT, $content, $headers); ?>
}
</script>
<a href="" onclick="Send Mail();" >Email</a>
ASKER
vnsmanian2006:
the script doesn't work
it auto send mail when page loads and email body is blank
kiranvj:
I would prefer a script that does not require another page
Any other ideas
the script doesn't work
it auto send mail when page loads and email body is blank
kiranvj:
I would prefer a script that does not require another page
Any other ideas
ASKER
kiranvj:
I tried your script it would work fine but the body content of the email does not pass over.
The email sends the subject sends but the $content, $headers does not send.
I got this variables with this code
<?php ob_start();?>
<?php $content=ob_get_flush();
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
?>
I tried your script it would work fine but the body content of the email does not pass over.
The email sends the subject sends but the $content, $headers does not send.
I got this variables with this code
<?php ob_start();?>
<?php $content=ob_get_flush();
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
?>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
page1.php
<script language="javascript">
function SendMail()
{
window.location.href='page
}
</script>
<a href="" onclick="Send Mail();" >Email</a>
page2.php
<?php
mail(MAIL_ADDRESS, MAIL_SUBJECT, $content, $headers);
header("Location:page1.php