$fax1 = trim($_POST["fax1"]); $comment = addslashes(trim($_POST["text1"])); //post elements $target_dir = "/var/www/html/new/img/{$img}"; $target_file = $target_dir . basename($_FILES["img"]["name"]); $img_var = basename($_FILES["img"]["name"]); move_uploaded_file($_FILES["img"]["tmp_name"], $target_file); //image upload $name_fields_presence = array("username", "password", "email", "first_name", "last_name", "pno", "employement", "employer", "street", "city", "state", "zip", "fax", "street1", "zip1", "fax1"); all_prestnt($name_fields_presence); //values are present or not $fields_max_length = array("username" => 20, "password" => 40, "first_name" => 20, "last_name" => 20, "pno" => 15); validate_max_lengths($fields_max_length); //max length check $fields_min_length = array("username" => 8, "password" => 8, "email" => 8, "pno" => 9); validate_min_lengths($fields_min_length); if (!preg_match('/^[a-z0-9_-]+@[a-z0-9._-]+\\.[a-z]+$/i', $email)) { $errors["email"] = " wrong" . ucfirst("email") . " pattern "; } //email format checking//for email varification; $output = form_errors($errors); //end of validations if (!$output) { $activate = md5(uniqid(rand(), true)); //creating new unique activation code $q = "UPDATE reg SET user_name='{$username}', \n\t\t\t\t\tpassword='******', \n\t\t\t\t\temail_id='{$email}', \n\t\t\t\t\tfirst_name='{$first_name}', \n\t\t\t\t\tlast_name='{$last_name}', \n\t\t\t\t\tmiddle_name='{$middle_name}', \n\t\t\t\t\tph_no='{$pno}', \n\t\t\t\t\temployement='{$employement}', \n\t\t\t\t\temployer='{$employer}', \n\t\t\t\t\tstreet='{$street}', \n\t\t\t\t\tcity='{$city}', \n\t\t\t\t\tstate='{$state}', \n\t\t\t\t\tzip='{$zip}', \n\t\t\t\t\tfax='{$fax}', \n\t\t\t\t\tstreet1='{$street1}', \n\t\t\t\t\tcity1='{$city1}', \n\t\t\t\t\tstate1='{$state1}', \n\t\t\t\t\tzip1='{$zip1}', \n\t\t\t\t\tfax1='{$fax1}', \n\t\t\t\t\tcomment='{$comment}', \n\t\t\t\t\tdob='{$dob}', \n\t\t\t\t\timg='{$img_var}' WHERE id='{$id}'"; if (mysqli_query($connection, $q)) { header("Location:detail.php"); } else { ?> <div class="colo"><?php
require_once "../includes/validation_functions.php"; confirm_login(); find_selected_page(); if (!$current_subject) { //must have subject id if we want to edit it redirect_to("manage_content.php"); } if (isset($_POST['submit'])) { //Process the form // Validations $required_fields = array("menu_name", "position", "visible"); validate_presence($required_fields); $fields_with_max_lengths = array("menu_name" => 30); validate_max_lengths($fields_with_max_lengths); $fields_with_min_lengths = array("menu_name" => 3); validate_min_lengths($fields_with_min_lengths); if (empty($errors)) { //Perform Update $id = $current_subject["id"]; $menu_name = mysql_prep($_POST["menu_name"]); $position = (int) $_POST["position"]; $visible = (int) $_POST["visible"]; // Perform database query $query = "UPDATE subjects SET "; $query .= "menu_name = '{$menu_name}', "; $query .= "position = {$position}, "; $query .= "visible = {$visible} "; $query .= "WHERE id = {$id} "; $query .= "LIMIT 1"; $result = mysqli_query($connection, $query); if ($result && mysqli_affected_rows($connection) >= 0) {