SORU
13 ŞUBAT 2009, Cuma


İki tane form düğmeleri gönder

İki tane vargönderform düğme. Nasıl bir tarafı hit oldu belirleyebilirim?

CEVAP
13 ŞUBAT 2009, Cuma


Her giriş farklı bir değer verir ve aynı ismi kullanabilirsin:

<input type="submit" name="action" value="Update" />
<input type="submit" name="action" value="Delete" />

Kodu görmek için kontrol tetiklendi sonra:

if ($_POST['action'] == 'Update') {
    //action for update here
} else if ($_POST['action'] == 'Delete') {
    //action for delete
} else {
    //invalid action!
}

Tek sorun içinde giriş metin için mantık kravat. Ayrıca her biri benzersiz bir ad verin ve sadece giriş varlığı için: $_POST kontrol edebilirsin

<input type="submit" name="update_button" value="Update" />
<input type="submit" name="delete_button" value="Delete" />

Ve kodu:

if (isset($_POST['update_button'])) {
    //update action
} else if (isset($_POST['delete_button'])) {
    //delete action
} else {
    //no button pressed
}

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Google Developers

    Google Devel

    23 AĞUSTOS 2007
  • Munchkin the Teddy Bear

    Munchkin the

    30 EYLÜL 2011
  • MofoHifi Records

    MofoHifi Rec

    15 HAZİRAN 2006