perastikos1 perastikos1 - 3 months ago 6x
PHP Question

When sending php variable in a href body i cant access variable in new page

I have this code

$sucess_image = '';
$body = "<a href=\"\"{$orderId}\"><img src='$sucess_image' /></a>";
$from = "<>";
$to = "<$email>";
$subject = 'test';
$newsubject = '=?ISO-8859-7?B?' . base64_encode($subject) . '?=';
$host = "";
$username = "";
$password = "xxx";
$headers = array(
'MIME-Version' => '1.0"\r\n"',
'Content-Type' => 'text/html; charset=UTF-8"\r\n"',
'Content-Transfer-Encoding: quoted-printable' => 'base64',
'From' => $from,
'To' => $to,
'Cc' => $cc,
'Subject' => $newsubject
$smtp = Mail::factory('smtp', array(
'host' => $host,
'auth' => true,
'username' => $username,
'password' => $password
$mail = $smtp->send($to, $headers, $body);

in the orderid is empty, the problem is that this variable has value when i send it to email, is there any problem in code and i cant pass the variable?


Your string is malformed -

 $body ="<a href=\"{$orderId}\"><img src='$sucess_image' /></a>";

Replace yours with this - and watch your quotes!

Personally i find it easier to use singles quote instead of double quotes inside variables - like:

$body ="<a href='".$orderId."'><img src='".$sucess_image."' /></a>";

but its down to person taste... but you may find it easier to!

I'm not sure - i could be wrong... but try removing:

'Content-Transfer-Encoding: quoted-printable' => 'base64',