I have an issue while sending email to user using PHP. I am binding some value inside the email template but not getting those value inside the template while that sent to user's inbox. I am explaining my code below.
$msgSub="Login credentials and verification link for Spesh";
$u_name='Username-"'.$email.'"';
$u_pass='Password-"'.$password.'"';
$url='http://oditek.in/spesh/mobileapi/categoryproduct.php?item=4&acn=2&email='+$email;
ob_start();
include "verification.php";
$msg_body=ob_get_clean();
$is_send=sendMail($email,'info@thespesh.com',$msgSub,$msg_body);
verification.php:
<br /><br />
<b><?php echo $u_name ?></b><br /><br />
<b><?php echo $u_pass ?></b>
<b><?php echo $url ?></b>
<br /><br />
function sendMail($to,$from,$subject,$msg_body){
$headers = "MIME-Version: 1.0" . "
";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "
";
$headers .= 'From: '.$from . "
";
$id=mail($to,$subject,$msg_body,$headers);
if($id){
return 1;
}else{
return 0;
}
}
Here I am getting value for $u_name and $u_pass
but for $url
the value is coming 0
. In the first file I have already declared the value for url
. The value of url should come.Please help me.
The problem is obviously on the way $url
is set:
$url = 'http://.../categoryproduct.php?item=4&acn=2&email=' + $email;
(I removed some unimportant part of the first string to let the issue come into focus).
The addition operator (+
) computes the sum of its operands. If the operands are strings they are first converted to numbers. When a string is converted to a number, only the maximum-length prefix of the string that looks like a number is used, the rest is ignored. In this code the two strings start with letters, not digits, that's why they both are converted to 0
(zero).
To concatenate strings, use the concatenation operator (.
):
$url = 'http://oditek.in/spesh/mobileapi/categoryproduct.php?item=4&acn=2&email='
. $email;