Page 3 of 3

Re: Why am I seeing the PHP code in my Browser?

Posted: Tue Aug 11, 2009 9:56 am
by sirab33
well you're right - but its been inconsistent.

At first the FORM didn't work without the full 127.0.0.1 path in the ACTION, but then I just tried it again and it was working.

Dunno, maybe I was still opening it from within the browser without using the 127.0 etc path - just cause that's how I've been opening web pages for the past 18 years :-) (or by draggin-and-droppin them on the browser icon- that won't fly here anymore, will it?)

Will pay very careful attention to this from now on for sure.

Its yet another whole new "world" this PHP stuff - kinda neat :-)

Anyway, thanks again! 8)
-S


robnet wrote:Great stuff!

Bear in mind though that if you view the initial html file via the server you shouldn't need to add the full (absolute) link. So if you visit http://127.0.0.1/file-with-form.html and within that form you just use href="message.php" it should resolve it correctly.

Ultimately it's best when dealing with any server side code that you always make the requests through the server. - Even for pure html or javascript. That way if you ever do need to link to your php you don't have to use the absolute links and it's more like a production environment which will make it easier to publish.

For example, if you want to upload your code to a webserver on the net and it still has the href="http://127.0.0.1/" part in it you will get errors because the page won't exist (except on your dev box!).