Created
September 6, 2015 16:35
-
-
Save AriffAzmi/111971b0742ae63e342d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
include 'config.php'; | |
if (isset($_POST['update']) && $_FILES['logo_name']) { | |
$menu_id = $mysqli->real_escape_string($_POST['menu_id']); | |
$menu_name = $mysqli->real_escape_string($_POST['menu_name']); | |
$menu_price = $mysqli->real_escape_string($_POST['menu_price']); | |
$menu_description = $mysqli->real_escape_string($_POST['menu_description']); | |
$logo_name = $_FILES['logo_name']['name']; | |
$tmp_name = $_FILES['logo_name']['tmp_name']; | |
$pathAndname = "uploads/img/".$logo_name; | |
$move_logo = move_uploaded_file($tmp_name, $pathAndname); | |
if ($_FILES['logo_name']['size'] > 0) { | |
if (!($_FILES['logo_name']['type'] =="image/jpeg" OR $_FILES['logo_name']['type'] =="image/png")) { | |
echo '<script>' . 'alert("Only image allowed with format Jpg or Png!");' . '</script>'; | |
echo '<script>' . 'window.location.href="update.php";' . '</script>'; | |
} | |
else { | |
$Q = "UPDATE menu SET menu_name = '$menu_name', menu_price = '$menu_price', menu_description = '$menu_description', | |
menu_logo = '$pathAndname' WHERE id ='". $menu_id ."'"; | |
$R = $mysqli->query($Q); | |
if ($R) { | |
echo '<script>' . 'alert("Menu successfully updated");' . '</script>'; | |
echo '<script>' . 'window.location.href="home.php";' . '</script>'; | |
} | |
else{ | |
echo "Something wrong with query"; | |
} | |
} | |
} | |
else { | |
$Q = "UPDATE menu SET menu_name = '$menu_name', menu_price = '$menu_price', menu_description = '$menu_description' WHERE id = '" . $menu_id . "'"; | |
$R = $mysqli->query($Q); | |
if ($R) { | |
echo '<script>' . 'alert("Menu successfully updated");' . '</script>'; | |
echo '<script>' . 'window.location.href="home.php";' . '</script>'; | |
} | |
else{ | |
echo "Something wrong with query update(No files)"; | |
} | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment