Jump to content


Photo

Switch or Multi-Page?


  • Please log in to reply
11 replies to this topic

#1 steelmanronald06

steelmanronald06
  • Staff Alumni
  • Advanced Member
  • 2,004 posts
  • LocationOk

Posted 18 September 2006 - 09:27 PM

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?

#2 effigy

effigy
  • Staff Alumni
  • Advanced Member
  • 3,600 posts
  • LocationIL

Posted 18 September 2006 - 10:08 PM

I use a switch where the cases can call functions and/or require pages. I think this combination keeps things clean and organized.
Regexp | Unicode Article | Letter Database
/\A(e)?((1)?ff(?:(?:ig)?y)?|f(?:ig)?)\z/

#3 448191

448191
  • Staff Alumni
  • Advanced Member
  • 3,545 posts
  • LocationNetherlands

Posted 19 September 2006 - 06:50 AM

I use a router and contollers, like in this article:

http://www.phpit.net...ple-mvc-php5/3/

#4 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 19 September 2006 - 02:36 PM

Switches or similar thing. I like eg:
index.php?page=register
index.php?page=login
over
register.php
login.php

#5 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 19 September 2006 - 04:07 PM

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 really 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 were 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.
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#6 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 19 September 2006 - 04:24 PM

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.


You could have two buttons. One saying 'Finish registration' and another one saying 'Enter more details'.

#7 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 19 September 2006 - 04:38 PM

well yeah, i can think of lots of reason why your registration could have more than one page, but i'm just wondering why you would 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 for 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.
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#8 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 19 September 2006 - 06:20 PM

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.

#9 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 19 September 2006 - 06:39 PM

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. 
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#10 steelmanronald06

steelmanronald06
  • Staff Alumni
  • Advanced Member
  • 2,004 posts
  • LocationOk

Posted 19 September 2006 - 07:28 PM

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.

#11 roopurt18

roopurt18
  • Staff Alumni
  • Advanced Member
  • 3,749 posts
  • LocationCalifornia, southern

Posted 20 September 2006 - 05:56 AM

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.
PHP Forms : Part I | Part II

JavaScript: Singleton

http://www.rbredlau.com

#12 Jenk

Jenk
  • Members
  • PipPipPip
  • Advanced Member
  • 778 posts

Posted 21 September 2006 - 02:10 PM

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)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users