Jump to content

Archived

This topic is now archived and is closed to further replies.

steelmanronald06

Switch or Multi-Page?

Recommended Posts

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?

Share this post


Link to post
Share on other sites
I use a switch where the cases can call functions and/or require pages. I think this combination keeps things clean and organized.

Share this post


Link to post
Share on other sites
I use a router and contollers, like in this article:

http://www.phpit.net/article/simple-mvc-php5/3/

Share this post


Link to post
Share on other sites
Switches or similar thing. I like eg:
index.php?page=register
index.php?page=login
over
register.php
login.php

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
[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'.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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. 

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.