search

Home  >  Q&A  >  body text

php - tp's automatic verification does not work

This is the front desk

This is the Cate controller
##This is the Model template

The problem is that the data can be inserted into the database normally, but it cannot be verified whether it is empty? Please help me find out why?

世界只因有你世界只因有你2745 days ago488

reply all(3)I'll reply

  • PHP中文网

    PHP中文网2017-05-27 17:45:50

    Just check whether I('post.catename') is empty in the controller

    reply
    0
  • 怪我咯

    怪我咯2017-05-27 17:45:50

    Is the code in the Cate controller written wrong? . .

    $data['catename'] = I('catename'); Is this line wrong?

    It should be:
    $data['catename'] = I('post.catename');
    Let’s do this.

    In fact, you don’t need to write it again to get it. The direct create method will get all the data requested by the front desk

    Another thing to note is that the create method only accepts post request data by default when you have not modified the underlying code

    reply
    0
  • 某草草

    某草草2017-05-27 17:45:50

    I mean, to refute the above, there is no problem with I ("catename"). I forgot the form verification, but you can try the following test

    1. Use a custom verification function. You can see whether verification is called (see how the document defines it)

    2. Verify the length, because the value obtained by the I() function is not null but an empty string.

    reply
    0
  • Cancelreply