Right now i have 6 files:

Main.php = The login page
Info.php = The first page seen after login
ForgetPass1.php = The first page for password recovery
ForgetPass2.php = The first page for password recovery


functions.php = Holds all the php functions used in all websites including:
-logout()
-confirmUser()
-SQL_Connection()
-checkLogin()
-displayLogin()
-displayPassForm1()
-displayPassForm2()
-checkPassForm1()
-checkPassForm2()
-gentempPass()
-redirect()
-stripInjection
-mysql_prep
-onlyInt()


posts.php - Holds all the post checking and alittle javascript including
-post for login
-post for password recovery form 1
-post for password recovery form 2

Basically, i require functions.php and posts.php on all main, info, forgetpass1 and forgetpass2. Is it bad to have all php functions in one file and all posts in another file? Should i have a php file for each function? Should i have a folder in my directory with the seperated functions.php and posts.php? Would my server be one heavy load if I include A LOT of functions in functions.php and have it required(included) on every page even if im only using one or two functions?

Its Okay to have your functions all in one place (file) and I like to do that in my projects and even wordpress and joomla works in this modulized way , in fact its good practice

- its good practice also to put all your files that will be included or required in separate directory and call it 'includes' for example
-to have pretty code I suggest that you have one file and lets name it 'initialize.php' and in this file you require all the files that you need to require in your project like functions and database connections and sessions ...etc and only require this file whenever you need it

-Functions processing does not consumes a lot of server processing and loading actually what makes it heavy the tons of connections you make with database , so try make them minimum as you can

hey dude. it dpends on the logic of your program. let me guess. I think you are creating a master content page right? the case is as I said... it depends. if you ask me why... I'll tell you. You should handle different variables even if they will only arrive at the same function bcoz they come from different pages. the only thing here is you only at least 2 session files typically the require() and the cookie_session(). cookie that will hndle the variables and require that will call wht page was that function

Nothing wrong with that.....Also it is good to separate them..

hey dude. it dpends on the logic of your program. let me guess. I think you are creating a master content page right? the case is as I said... it depends. if you ask me why... I'll tell you. You should handle different variables even if they will only arrive at the same function bcoz they come from different pages. the only thing here is you only at least 2 session files typically the require() and the cookie_session(). cookie that will hndle the variables and require that will call wht page was that function

I have no idea what you just said..

Nothing wrong with that.....Also it is good to separate them..

Uhhh your first comment contradicts your second. Can you please explain what your getting at?

to have pretty code I suggest that you have one file and lets name it 'initialize.php' and in this file you require all the files that you need to require in your project like functions and database connections and sessions ...etc and only require this file whenever you need it

I can’t do that, since im not including functions.php and posts.php at the same place in my webpages. I need functions.php required at the top and posts.php required at the bottom of any webpage.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.