1

So when users sign up, they get an email, and I'm trying to add an image to that email. That image is dynamically generated using php, so its not a static url. The code works, but when I add it to the email code, the image shows up blank. I know the code works because I have echo'd the body, and the image showed up fine in my browser but empty in the email (i have a border around the image, the border shows up, inside is empty).

$img = "<img src='../inc/barcode.php?id=".$regid."' style='padding:5px; border:2px dashed '/>"; 

elsewhere

$body .= $img;

So does anyone know why the image won't display, and how I could make it so it does?

Also, another question to kind of go off this, how do I display a generic url for the image so that instead of /img.php?id="" it just reads /img.php or something.

gta0004
  • 508
  • 4
  • 11
  • 29
  • 1
    how is the image placed in the email, as a link, attachment or embedded? If it's a link show an example of it `/img.php?id=1` is local `http://domain.com/img.php?id=1` is not – Waygood Mar 18 '13 at 16:46
  • @Waygood Edited it in. Its embedded – gta0004 Mar 18 '13 at 16:50
  • 1
    It's a __link__ to the parent folder of the computer thats reading it. Put the full URL including the domain name in there to – Waygood Mar 18 '13 at 16:53
  • write one or search the internet for a two way encryption function (ie encode/decode) then encode `id` before sending and decode in barcode.php – Waygood Mar 18 '13 at 17:00
  • http://stackoverflow.com/questions/1391132/two-way-encryption-in-php – Waygood Mar 18 '13 at 17:01

1 Answers1

1

You are using relative links, not absolute.

$img = '<img src="http://www.mydomain.com/inc/barcode.php?id='.$regid.'" style="padding:5px; border:2px dashed" />';
Waygood
  • 2,657
  • 2
  • 15
  • 16