steelmanronald06 Posted September 18, 2006 Share Posted September 18, 2006 I have recently recoded my entire website using Switch on most of it. I have scripts that at one point required up to six different pages (User Registration), that are now all in /register/index.php as a switch. My question is what is best used here? Multi-Page or a switch? I know some hosts will sometimes allow you to only have a max amount of pages created, on top of the WebSpace they give you. So in that instance it would be good to use less pages, but say your like me and have your own server. Does it matter? Personal preferences? Quote Link to comment https://forums.phpfreaks.com/topic/21197-switch-or-multi-page/ Share on other sites More sharing options...
effigy Posted September 18, 2006 Share Posted September 18, 2006 I use a switch where the cases can call functions and/or require pages. I think this combination keeps things clean and organized. Quote Link to comment https://forums.phpfreaks.com/topic/21197-switch-or-multi-page/#findComment-94252 Share on other sites More sharing options...
448191 Posted September 19, 2006 Share Posted September 19, 2006 I use a router and contollers, like in this article:http://www.phpit.net/article/simple-mvc-php5/3/ Quote Link to comment https://forums.phpfreaks.com/topic/21197-switch-or-multi-page/#findComment-94479 Share on other sites More sharing options...
Daniel0 Posted September 19, 2006 Share Posted September 19, 2006 Switches or similar thing. I like eg:index.php?page=registerindex.php?page=loginoverregister.phplogin.php Quote Link to comment https://forums.phpfreaks.com/topic/21197-switch-or-multi-page/#findComment-94659 Share on other sites More sharing options...
.josh Posted September 19, 2006 Share Posted September 19, 2006 a multi-page registration, spread throughout several script files is going to require the use of sessions, cookies, or hidden inputs. or i guess you could also store info in a db or flatfile if you [i]really[/i] wanted to.. but on the other hand, having it all on one page will reduce methods used to just post vars. either way you are going to have conditioning for form validation. I suppose it probably boils down to preference, but I personally think it would be easier to follow if all of the form validation conditioning were in one place, rather than spread out over several pages. and on that note, if you [i]were[/i] to have a registration spread out over several pages, at what point does your script start spitting out errors? After each page, no letting the user continue to the next page until the first one is acceptable? Or waiting until the end? That's going to make a big difference in coding, as well.Also I have to kind of wonder why your registration process is taking more than one page to begin with? I personally think that ideally, a registeration script should be no more than one page to begin with. Get the vitals, and that's it. Anything else should be on some other "account preferences, settings, optional info, etc.." page after the user is registered and logged in and looking at their acct. info. I guess that's just me. But I think if I did somehow have to extend a registration script past 1 page, pretty much do it the same as effigy. Quote Link to comment https://forums.phpfreaks.com/topic/21197-switch-or-multi-page/#findComment-94719 Share on other sites More sharing options...
Daniel0 Posted September 19, 2006 Share Posted September 19, 2006 [quote author=Crayon Violent link=topic=108547.msg437308#msg437308 date=1158682021]Also I have to kind of wonder why your registration process is taking more than one page to begin with? I personally think that ideally, a registeration script should be no more than one page to begin with. Get the vitals, and that's it. Anything else should be on some other "account preferences, settings, optional info, etc.." page after the user is registered and logged in and looking at their acct. info. I guess that's just me. [/quote]You could have two buttons. One saying 'Finish registration' and another one saying 'Enter more details'. Quote Link to comment https://forums.phpfreaks.com/topic/21197-switch-or-multi-page/#findComment-94729 Share on other sites More sharing options...
.josh Posted September 19, 2006 Share Posted September 19, 2006 well yeah, i can think of lots of reason why your registration [i]could[/i] have more than one page, but i'm just wondering why you [i]would[/i] do it. I'm not saying my methods are the best, but it just seems to me that the initial registration process should be as simple, fast and convenient as possible. What exactly someone is registering [i]for[/i] plays an important factor in how long a registration form should be, obviously, but i personally feel that KISS should always be at the front of your mind. Quote Link to comment https://forums.phpfreaks.com/topic/21197-switch-or-multi-page/#findComment-94740 Share on other sites More sharing options...
Daniel0 Posted September 19, 2006 Share Posted September 19, 2006 It do not necessarily have to be in more than one page. It could be hidden, and then the 'Enter more details'-button would show the rest of the form using javascript. Quote Link to comment https://forums.phpfreaks.com/topic/21197-switch-or-multi-page/#findComment-94821 Share on other sites More sharing options...
.josh Posted September 19, 2006 Share Posted September 19, 2006 well again, that's just going into personal style. i personally try to avoid javascript as any kind of solution, as it can be so easily turned off by the user. Quote Link to comment https://forums.phpfreaks.com/topic/21197-switch-or-multi-page/#findComment-94841 Share on other sites More sharing options...
steelmanronald06 Posted September 19, 2006 Author Share Posted September 19, 2006 here is my register.php default html form that submits to the next case case check checks for html, ensures all fields are posted, ensures that email and username are unique, and ensures that the password matches the confirm password case register this page registers them in a database, creates their profile, sets their PM inbox up, and sends them an email case error any errors and stuff that is thrown is redirected here and other statements show the user his/her error, sends emails to admin, etc. Quote Link to comment https://forums.phpfreaks.com/topic/21197-switch-or-multi-page/#findComment-94874 Share on other sites More sharing options...
roopurt18 Posted September 20, 2006 Share Posted September 20, 2006 I personally do not like to use includes. I find that they make the code harder to read and follow, encourage the use of global variables, and in general are a PITA. For multipage forms, I prefer to use a hidden page parameter and use this value to choose which page to display. Quote Link to comment https://forums.phpfreaks.com/topic/21197-switch-or-multi-page/#findComment-95113 Share on other sites More sharing options...
Jenk Posted September 21, 2006 Share Posted September 21, 2006 Multiple pages requires duplicate code. Duplicate code requires more time. More time is less efficient. Less efficient is more cost. More cost is more expensive.and for reference, you are describing the Front Controller, or Page Controller when you refer to 'using switches' (and switch() is just one of many ways to achieve such a task) Quote Link to comment https://forums.phpfreaks.com/topic/21197-switch-or-multi-page/#findComment-96093 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.