tags:

views:

37

answers:

2
<script type="text/javascript">
var head= 23;
</script>

<?php
$h="<script language='javascript'> document.write(head);</script>";

$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=ISO-8859-1" . "\r\n";

 $mail_from='[email protected]';
 $name="husssain";
 $headers.="From: $name <$mail_from>";
 $con="Welcome to world";
 $to ="[email protected]";
 $send_contact = mail($to,$con,$h,$headers); 
?>

then i send the $h to my mail id but i recieve only this <script language='javascript'> document.write(head);</script>

+1  A: 

Consider output buffering. Better yet, consider designing your script so that the contents of the message come from a proper template.

And you realize that JavaScript is highly unlikely to run within a received email, right?

Jim Puls
+1  A: 

Programatically, you can't do that.

The PHP code renders before the Javascript on the page. In short, the PHP is handled first then the Javascript is written to the page. You need to have the Javascript send to a page or use AJAX to call a mail page.

Alex