Welcome Guest, Not a member yet? Register   Sign In
form validation help PLEASE

notice the yellow.. what i really meant was

if(NOT logged in)

that makes sense, where do you suggest i put the login validation i have in the login controller? in the mains controller? i kind of wanted to keep all of my form validation in one place separate from everything, is that a bad idea?.

Just copy everything over and change the Login Index function to be called Login (that way if people want to log in its mains/login) and make sure your form posts to the new location, other than that it should be good.

If all you have are the two functions for the login stuff then it probably won't be that big of a deal, if you were planning a more complex site with editing profiles, resetting passwords, etc, i might suggest naming Login to User and putting the "user" functionality stuff in there, really with MVC you can keep everything in one controller if you want, but I prefer to make the URLs also mean something (eg /user/login, /user/profile, etc)

yeah its fairly complex. Ive coded registering, logging in, personal messages, profiles, editing profiles, creating events, editing events, commenting on events, creating forum topics, commenting on forum topics, etc. I wanna get this organization right because im redoing a hell of a lot of stuff.

well let me ask you this...if i have my header(with the login/logged portion) which im gonna display on every page couldn't i just save that as view. It may be bad practice because its not separating html markup from php if statements and what-not etc, but i then would be able to call it across all controllers.

The structure of where you put things in what controller is entirely up to you, as long as it works correctly. What I end up doing is having a view structure look like this:


and in home.php


That way im only calling one view from the controller, but then again its entirely up to you. You can have php in your view, its not a bad thing, you can even call models from your view, i've had to do that before. As long as it works and you're happy with it then it's ok.

yeah but in my header i will have a login that will be at the top of every page and i can't figure out where the heck to put the login validation for that if i will be using multiple controllers. It seems redundant and bad practice to have to copy/paste it into every controller.

If a person logs in will you take them to the previous page that they were on or to a general page? If its a general page then having the login post to one controller only is good, if you'll take them to the previous page use <input type='hidden' name='page' value='CURRENT_PAGE' /> and redirect from your login controller to that. Say the login fails, take them to the Login Controller and display a page dedicated to login (just the username and password) with the error message. Does this make sense?

yeah that makes sense. So now your suggesting that i should keep the login controller separare from my main controller?

heres how i see my events site working

main controller -- mysite.com/main
-displays all events

then i would break into categories

then i would have a user controller
-display users and handle creation of users and editing of profiles

then i would have an event controller
-display events, edit events

then i guess i would have a login controller
-handle logins and redirect to a register page if login fails

That would work just fine.

Theme © iAndrew 2016 - Forum software by © MyBB