scuff Posted December 6, 2009 Share Posted December 6, 2009 Is it possible to do something like this: page 1: <img src="page2.php"> page2.php: <?php header("Location: http://www.example.com/"); ?> Basically I want to know if page1 can redirect to a page specified by page 2 using img src. Is that possible? Link to comment https://forums.phpfreaks.com/topic/184202-image-redirect-using-php/ Share on other sites More sharing options...
Brandon_R Posted December 6, 2009 Share Posted December 6, 2009 You cannot use the header function if output has already started or sent. If you visit page2.php directly it will redirect to example.com however embedding it in an HTML page will not work. You may want to try <meta http-equiv="refresh" content="0;url=http://example.com/"> Link to comment https://forums.phpfreaks.com/topic/184202-image-redirect-using-php/#findComment-972502 Share on other sites More sharing options...
scuff Posted December 6, 2009 Author Share Posted December 6, 2009 I tried putting <meta http-equiv="refresh" content="0;url=http://example"> on page2.php but it didn't work, so basically you can't redirect from img src, right? Link to comment https://forums.phpfreaks.com/topic/184202-image-redirect-using-php/#findComment-972503 Share on other sites More sharing options...
oni-kun Posted December 6, 2009 Share Posted December 6, 2009 I tried putting <meta http-equiv="refresh" content="0;url=http://example"> on page2.php but it didn't work, so basically you can't redirect from img src, right? Why are you even doing this? The image tag is for an image, if you didn't know, and the browser will only render it as so. If that would allow redirecting the bloody web would be 1000x as spammy than before. Page2.php can redirect to http://www.example.com/image.jpg. Link to comment https://forums.phpfreaks.com/topic/184202-image-redirect-using-php/#findComment-972504 Share on other sites More sharing options...
scuff Posted December 6, 2009 Author Share Posted December 6, 2009 lol good just making sure for security reasons on my site I'm trying to disable every possible way of redirecting Link to comment https://forums.phpfreaks.com/topic/184202-image-redirect-using-php/#findComment-972505 Share on other sites More sharing options...
oni-kun Posted December 6, 2009 Share Posted December 6, 2009 lol good just making sure for security reasons on my site I'm trying to disable every possible way of redirecting Only thing you'd need to watch out for is XSS, which relates to problems with javascript. The IMG tag will just output a resulting image if it is supported, such as mimetype image/jpg(gif/png/xmp/) Link to comment https://forums.phpfreaks.com/topic/184202-image-redirect-using-php/#findComment-972508 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.