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

  • Arun Kumar

    Arun Kumar

    18 Mart 2010
  • GUN-TIME with Brandon

    GUN-TIME wit

    3 ŞUBAT 2009
  • Microsoft Help & Training Videos

    Microsoft He

    31 Mart 2009