Jump to content

Entire Login Script Before The <html> Tags?


MrFish
 Share

Recommended Posts

I attempted to put an entire login script before the <html>. Since you have to set cookies before the html begins I thought, might as well just do the whole thing before the html tags! (like searching the mysql database and stuff). Will this work? What happens when you put things before the html tags? I know I put javascript before them once and it worked fine.

Link to comment
Share on other sites

By the way, you can't access cookies anywhere on the same script they are created in. The page has to be reloaded at least once.

Link to comment
Share on other sites

Sure works but there will be alot things to keep track on. I prefer to include php files with functions or statment where they are needed and I can add them as many times I want so I don't need too write my code twice.Any how if you are going to have all php codes over the html I strongly recommend too make a include so you get the html separated from the php, just like you separate the css. Some php codes still needs to be on the main page like "session_start();" :)

Link to comment
Share on other sites

You can actually include the file with the session_start() call - I do it all the time. In PHP, including a page is equivalent to copying all its code and pasting it where the include statement is.

Link to comment
Share on other sites

You can actually include the file with the session_start() call - I do it all the time. In PHP, including a page is equivalent to copying all its code and pasting it where the include statement is.
I didn't know I thought if you wanted a session_start it needed to be the first line :) Good to know I can add it to my includes :)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...