CodeIgniter Hata - Undefined özellik: CI_Input :: $ post

2 Cevap php

Ben CodeIgniter için yeni ve formu teslim edilmiş olup olmadığını belirlemek ve sonra varsa belli bir görünümünü görüntülemek için aşağıdaki koşullu kullanmaya çalışıyorum. Ben nedense başlığında hata var ve daha yarım ve saat için sorun giderme olmuştur. Ben bu sorunu çözme hakkında gitmek nasıl bilen var mı? Teşekkürler!

if($this->input->post->lastName){

    // load view if form was submitted

} else {

    // load other view

}

2 Cevap

deneyin:

if($this->input->post('lastName')){

    // load view if form was submitted

} else {

    // load other view

}

Ben,

Jayrox answer is correct, but you should be thinking of using the Form Validation class.

Form Doğrulama kılavuzunda belirtildiği gibi:

Before explaining CodeIgniter's approach to data validation, let's describe the ideal scenario:

  1. Bir form görüntülenir.
  2. Sen doldurun ve gönderin.
  3. If you submitted something invalid, or perhaps missed a required item, the form is redisplayed containing your data along with an error message describing the problem.
  4. Eğer geçerli bir formu teslim kadar bu süreç devam ediyor.

Alıcı ucunda, komut gerekir:

  1. Gerekli veriler için kontrol edin.
  2. Verify that the data is of the correct type, and meets the correct criteria. For example, if a username is submitted it must be validated to contain only permitted characters. It must be of a minimum length, and not exceed a maximum length. The username can't be someone else's existing username, or perhaps even a reserved word. Etc.
  3. Güvenlik verileri sterilize.
  4. Pre-format the data if needed (Does the data need to be trimmed? HTML encoded? Etc.)
  5. Veritabanında sokulması için verileri hazırlayın.

Although there is nothing terribly complex about the above process, it usually requires a significant amount of code, and to display error messages, various control structures are usually placed within the form HTML. Form validation, while simple to create, is generally very messy and tedious to implement.

Şerefe