if (!isset($_POST[$polje]) || empty($_POST[$polje]) && $_POST[$polje] != 0 || $_POST[$polje] == "") { $errors[] = $polje; } } $polje_sa_duzinom = array('menu_name' => 30); foreach ($polje_sa_duzinom as $polje => $max_duz) { if (strlen(trim(mysql_prep($_POST[$polje]))) > $max_duz) { $errors[] = $polje; } } if (empty($errors)) { $id = mysql_prep($_GET['subj']); $menu = mysql_prep($_POST['menu_name']); $position = mysql_prep($_POST['position']); $visible = mysql_prep($_POST['visible']); $rez = get_subject_by_id($_GET['subj']); $position_old = $rez['position']; if ($position_old != $position) { if ($position_old < $position) { for ($i = $position_old; $i < $position; $i++) { $new = $i + 1; $qry = "UPDATE subject SET"; $qry .= " position={$i}"; $qry .= "\tWHERE position={$new}"; mysql_query($qry, $conn); } } else { for ($i = $position_old; $i > $position; $i--) { $new = $i - 1; $qry = "UPDATE subject SET"; $qry .= " position={$i}";
<?php require_once "includes/connection.php"; require_once "includes/functions.php"; if (intval($_GET['subj']) == 0) { redirect_to("content.php"); } $id = mysql_prep($_GET['subj']); if ($subject = get_subject_by_id($id)) { $query = "DELETE FROM subject WHERE id={$id} LIMIT 1"; $result = mysql_query($query, $conn); if (mysql_affected_rows() == 1) { $message = "Record successfully deleted."; redirect_to("content.php"); } else { //Deletion failed echo "<p>Subject deletion failed.</p>"; echo "<p>" . mysql_error() . "</p>"; echo "<a href=\"content.php\">Back to Main Page</a>"; } } else { //subject didn't exist in database redirect_to("content.php"); } ?>
function find_selected_page() { global $sel_subject; global $sel_page; if (isset($_GET['subj'])) { $sel_subject = get_subject_by_id($_GET['subj']); $sel_page = get_default_page($sel_subject['id']); } elseif (isset($_GET['page'])) { $sel_subject = NULL; $sel_page = get_page_by_id($_GET['page']); } else { $sel_subject = NULL; $sel_page = NULL; } }
<?php // check if subject get set if (isset($_GET['subject'])) { $sel_subject = get_subject_by_id($_GET['subject']); } else { $sel_subject = NULL; } // check if subject get set if (isset($_GET['child'])) { $sel_subject_child = get_subject_by_id($_GET['child']); } else { $sel_subject_child = NULL; } // check if page get set if (isset($_GET['page'])) { $sel_page = get_page_by_id($_GET['page']); $sel_product = get_product_by_id($_GET['page'], ''); } else { $sel_page = NULL; $sel_product = NULL; } if (isset($_REQUEST['command']) || isset($_REQUEST['pid']) || isset($_REQUEST['productid'])) { // for add to cart if ($_REQUEST['command'] == 'add' && $_REQUEST['productid'] > 0) { $pid = $_REQUEST['productid']; $p_qty = $_REQUEST['productqty']; $p_note = $_REQUEST['productnote']; addtocart($pid, $p_qty, $p_note); header("location:shoppingcart.php?qty=" . $p_qty); exit;