What is the right way to handle $_POST data in MVC?

前端 未结 5 1100
时光取名叫无心
时光取名叫无心 2020-11-28 06:10

I have the common MVC situation in my PHP system: the Controller receive a request from the View containing $_POST data. Now I have th

5条回答
  •  难免孤独
    2020-11-28 06:39

    i am using Zend and following

    the 2nd option .

    Example a Registration form

    step- 1 the forms sends me the post value to the specified controller

    step -2 i will validate the form values for example ( mail and url and empty post values ) through server side validation .

    step -3 send the checked post data either in variable or has whole to the model .

    step 4- controller calls the model .

    step -5 the models inserts the post values and creates a new user .

    I think your second option is better regardless of framework or approah you use .

    note - same controller can handle everthing depends on your application logic .

     but i prefer to keep different controller for differnt user request and user types
    
     it helps in keeping code readable managebale .
    

提交回复
热议问题