Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 19
  1. #1
    Utente di HTML.it
    Registrato dal
    Jan 2008
    Messaggi
    14

    PHP e input form sto diventando pazzo

    ciao a tutti ragazzi,
    chiedo un consiglio.
    ho una pagina semplice in php con codice html che deve mandare ad un altra pagina php attraverso un form dei dati, ma ovviamente questi dati non vengono mandati.
    Vi posto il codice della pagina col FORM:

    <!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>
    e qui la pagina che dovrebbe ricevere
    codice:
    <?php $remove = $_POST['re']; print_r($_POST); echo $remove;?>
    l'array è vuoto, a me servirebbe il valore dell'hidden input.
    Perche non funziona? grazie per l'aiuto!

  2. #2
    Utente di HTML.it L'avatar di homerbit
    Registrato dal
    Dec 2005
    residenza
    Roma
    Messaggi
    1,380
    il codice è corretto e ti dirò...l'ho anche testato facendo una copia esatta quello che hai testato.

    Nel file cateogory.php ricevo esattamente questo:
    codice:
    Array ( [re] => 1 [rem] => Rimuovi ) 1
    controlla bene TUTTO
    If you think your users are idiots, only idiots will use it. DropBox

  3. #3
    Utente di HTML.it
    Registrato dal
    Jan 2008
    Messaggi
    14
    mi sta facendo uscire pazzo, a me da Array ( ). non ha senso!

  4. #4
    Moderatore di PHP L'avatar di Alhazred
    Registrato dal
    Oct 2003
    Messaggi
    12,505
    Nel codice che hai postato hai omesso qualcosa?
    Perché usi un enctype multipart/form-data se non devi inviare file?

  5. #5
    Utente di HTML.it L'avatar di homerbit
    Registrato dal
    Dec 2005
    residenza
    Roma
    Messaggi
    1,380
    posta tutto il codice responsabile
    If you think your users are idiots, only idiots will use it. DropBox

  6. #6
    Utente di HTML.it
    Registrato dal
    Jan 2008
    Messaggi
    14
    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
     
     ?>

  7. #7
    Utente di HTML.it
    Registrato dal
    Jan 2008
    Messaggi
    14
    questa è 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
     
     ?>

  8. #8
    Utente di HTML.it L'avatar di homerbit
    Registrato dal
    Dec 2005
    residenza
    Roma
    Messaggi
    1,380
    perchè? @$remove = $_POST['re'];
    sostituisci con
    $remove = $_POST['re'];
    If you think your users are idiots, only idiots will use it. DropBox

  9. #9
    Utente di HTML.it
    Registrato dal
    Jan 2008
    Messaggi
    14
    mi stampa questo
    codice:
    Notice: Undefined index: re in C:\Program Files (x86)\EasyPHP-12.1\www\restosystem\modules\category\remove_category.php on line 25
    Array ( )

  10. #10
    Utente di HTML.it L'avatar di homerbit
    Registrato dal
    Dec 2005
    residenza
    Roma
    Messaggi
    1,380
    nella pagina che riceve, inserisci solo le seguenti righe:
    Codice PHP:
    if(isset($_POST['rem'])){echo 'lol';}
    if(isset(
    $_POST['re']) ){$remove $_POST['re'];} else $remove '';

     
    print_r($_POST); 
    e vedrai che funziona, da qui cerca di risalire al tuo problema
    If you think your users are idiots, only idiots will use it. DropBox

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.