questo è la pagina che invia:
codice:
<?php
// Inialize session
session_start();
// Check, if user is already login, then jump log_in
if (!isset($_SESSION['restaurant_email'])) {
header('Location: login_restaurant.php');
}
if (!isset($_SESSION['restaurant_id'])) {
header('Location: login_restaurant.php');
}
//Query to the Database
$host_db = "localhost";
$user_db = "root";
$password_db = "";
$name_db = "system";
//connetto il database
$db = mysql_connect($host_db, $user_db, $password_db) or die ('Errore durante la connessione');
mysql_select_db($name_db, $db) or die ('Errore durante la selezione del db');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form name='form2' id="form2" action='category/remove_category.php' method='post' enctype="multipart/form-data">
<?php
?>
<input type="hidden" value="1" name='re' />
<input type="submit" id="rem" name="rem" value="Rimuovi" />
</form>
</body>
</html>
questa è la pagina che riceve
codice:
<?php
// Inialize session
session_start();
// Check, if user is already login, then jump log_in
if (!isset($_SESSION['restaurant_email'])) {
header('Location: login_restaurant.php');
}
if (!isset($_SESSION['restaurant_id'])) {
header('Location: login_restaurant.php');
}
//Query to the Database
$host_db = "localhost";
$user_db = "root";
$password_db = "";
$name_db = "system";
//connetto il database
$db = mysql_connect($host_db, $user_db, $password_db) or die ('Errore durante la connessione');
mysql_select_db($name_db, $db) or die ('Errore durante la selezione del db');
$restaurant_id = $_SESSION['restaurant_id'];
$restaurant_id = mysql_real_escape_string($restaurant_id);
if(isset($_POST['rem'])){echo 'lol';}
//INIZIO BLOCCO RIMUOVI CATEGORIA
@$remove = $_POST['re'];
print_r($_POST);
echo $remove;
if ( $remove == 1 ) {
echo 'aaaa';
@$create = $_POST['r_category'];
$create = mysql_real_escape_string($create);
$query = mysql_query("SELECT * FROM `category_menu` WHERE `restaurant_id` = '$restaurant_id' LIMIT 0, 30 ");
while ($row= mysql_fetch_array($query, MYSQL_ASSOC)) {
foreach ( $row as $chiave => $valore) {//controllo per trovare campo vuoto nel database
if ($row[$chiave] =="$create"){//controllo la categoria per prendere la $chiave
$check1 = $chiave;
}
}//chiusura foreach
if (isset($check1)){
mysql_query("UPDATE `category_menu` SET `$chiave` = '' WHERE `category_menu`.`restaurant_id` = '$restaurant_id'");
}
}// chiusura while
header('location: ' . $_SERVER['PHP_SELF']);
}//chiusura if ( $create == 1 )
//FINE BLOCCO RIMUOVI CATEGORIA
?>