I have a blog and one day I post a redirect page tutorial with php script within it. I saw that tutorial from a web and I want to post it to my blog too..

here is the script :


function redirect($url) {
	if (!headers_sent()) {
		header("Location: " . $url);
	} else {
		echo('<script>window.location = ' . $url . '</script>');

But, when I visit my blog, blogger said that the blog is not recognized. And on the address bar appeared "http://myblog.blogspot.com/ . $url ."
It looks that the redirect script run without parameter..
Why can it happen?!?

Hi there,
The problem is that your site is obviously running on an apache server so when the page loads, it parses your post as php instead of as plain text, this is actually a security flaw as your site should convert all special characters (that aren't disallowed) from a post to their html escape codes, for example '<' is '&lt;'. This conversion prevents your post from being interpreted as code.
And naturally, your script is running without a parameter, because the variable '$url' has not been declared on the page before the parser gets to your script.

I'll try it...

Hi. As I understand blogger supports php scripts? Can I integrate script like php forms to my blog? Will blogger support such script?

Member Avatar

I wouldn't have thought that it supports php. You can use the Data API with it off your own site if you like. One workaround would be an iframe with your php page in it.


I don't believe it I just fell into the trap of a necroposter. *Hangs head in shame* :(

I think you cannot put php there for security reasons.