PHP Code only works after refresh?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
akphidelt
Forum Newbie
Posts: 6
Joined: Wed Feb 13, 2008 2:09 pm

PHP Code only works after refresh?

Post by akphidelt »

Hi there, i'm running in to a weird little problem.

I'm using XAMPPlite and wrote a username/password php script

When I click login on my test page using internet explorer it shows the typed code first. Then after I hit refresh and click on retry it will show the actual php page. I can't for the life of me figure out why it won't show the php page when first clicking on login.

Does anyone have a clue on why this is happening. Let me know if you need any more information. Thanks a lot!

akphidelt
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: PHP Code only works after refresh?

Post by califdon »

Hard to say without seeing your code. If you post it, please enclose it in [syntax=php][/syntax] BBCode tags.
akphidelt
Forum Newbie
Posts: 6
Joined: Wed Feb 13, 2008 2:09 pm

Re: PHP Code only works after refresh?

Post by akphidelt »

pretty much any code in the php syntax for example... a simple code like this

Code: Select all

 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
    "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
 
<html>
<?php
 
 
echo "do you work?";
 
?>
</html>
 
When I open up this code which is saved as test.php in Internet Explorer, it will just show the code as written above. Then I refresh, click on retry, and then the code shows up blank.

Any ideas?
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: PHP Code only works after refresh?

Post by califdon »

akphidelt wrote:pretty much any code in the php syntax for example... a simple code like this

Code: Select all

 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
    "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
 
<html>
<?php
 
echo "do you work?";
 
?>
</html>
 
When I open up this code which is saved as test.php in Internet Explorer, it will just show the code as written above. Then I refresh, click on retry, and then the code shows up blank.

Any ideas?
My first thought would be the header; since I don't use the XHTML Doctype header, I'm unfamiliar with whether it has any little quirks, but it would be extremely easy to rule that out, just by omitting the header and seeing if it makes any difference in the behavior.

Beyond that, it sounds like your Apache is not configured properly. I can't explain why it would work the second time, but it surely must be that, since the only way it could send raw php code to the browser is if it is is not preprocessing it.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: PHP Code only works after refresh?

Post by Benjamin »

You are missing body tags as well.
Post Reply