From 8d9321225140a3db0b72796d4d0236d6cacfeb8a Mon Sep 17 00:00:00 2001 From: Nicolas BERNSTEIN Date: Sat, 17 Sep 2011 19:36:41 +0200 Subject: Started working on a study program. --- lib/deck/edent.php | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 lib/deck/edent.php (limited to 'lib/deck/edent.php') diff --git a/lib/deck/edent.php b/lib/deck/edent.php new file mode 100644 index 0000000..8bdfac3 --- /dev/null +++ b/lib/deck/edent.php @@ -0,0 +1,44 @@ + $card['deckid'], 'name' => $card['deckname']); + +$card_name = $card['name']; +$card_text = $card['text']; +if (isset($_POST['name']) && isset($_POST['text'])) { + $card_name = esca($_POST['name']); + $card_text = esca($_POST['text']); + $card_text_html = Markdown($card_text); + if ($card_name == "") { + $error = "You must give your card a name."; + } else if ($card_text == "") { + $error = "You must put some text in your card."; + } else if (mysql_fetch_assoc(sql("SELECT id FROM cards WHERE deck = " . $deck['id'] . " AND name = '" . escs($card_name)."' AND id != $cardid"))) { + $error = "You already have a card using that name."; + } else { + sql("UPDATE cards SET name = '" . escs($card_name) . "', text_md = '" . escs($card_text) . "', text_html = '" . escs($card_text_html) . "'" . + " WHERE id = $cardid"); + header("Location: view-deck-" . $deck['id']); + die(); + } +} + +$title = "Edit card in " . $deck['name']; +$fields = array( + array("label" => "Name : ", "name" => "name", "value" => $card_name), + array("label" => "Text : ", "name" => "text", "type" => "textarea", "value" => $card_text), +); +$validate = "Edit card"; + +require("tpl/deck/ef.php"); + -- cgit v1.2.3