form validation help PLEASE

#31
[eluser]dadamssg[/eluser]
notice the yellow.. what i really meant was

Code:
if(NOT logged in)

#32
[eluser]dadamssg[/eluser]
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?.

#33
[eluser]JHackamack[/eluser]
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)

#34
[eluser]dadamssg[/eluser]
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.

#35
[eluser]dadamssg[/eluser]
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.

#36
[eluser]JHackamack[/eluser]
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:

/Application/Views/global/header.php
/Application/Views/global/footer.php
/Application/Views/home.php

and in home.php

<?php
$this->load->view('global/header.php');
//HTML MARKUP
$this->load->view('global/footer.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.

#37
[eluser]dadamssg[/eluser]
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.

#38
[eluser]JHackamack[/eluser]
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?

#39
[eluser]dadamssg[/eluser]
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
-mysite.com/main/sports
-mysite.com/main/performance

then i would have a user controller
-display users and handle creation of users and editing of profiles
-mysite.com/user/profile/Bob

then i would have an event controller
-display events, edit events
-mysite.com/event/id/2345

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

#40
[eluser]JHackamack[/eluser]
That would work just fine.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.