Visualizzazione dei risultati da 1 a 5 su 5
  1. #1
    Utente di HTML.it
    Registrato dal
    Aug 2006
    Messaggi
    833

    Problema insert into e gestione variabili ricevute

    Ciao, volevo chiedervi se capite questi 2 problemi

    1) la pagina db_update6 passa giustamente delle variabili alla update8, il titolo
    della update8 ha le variabili corrette pero' quando le testo o le stampo non c'e' nessun
    valore.

    2) non funziona la insert into, ammetto che non so se e' giusta la sintassi.

    POSTO LE 2 PAGINE

    update6 (chiamante)

    <html>

    <?php
    define("PAGE_TITLE", "Customer Update");
    define("PHP_FILE_NAME", "db2_update6.php")
    ?>

    <title><?= PAGE_TITLE . " - " . PHP_FILE_NAME; ?></title>
    <body>

    <?php

    /* Reperimento variabile passata dalla lista server clienti db2_update7*/
    $customerSERCLI = $_GET["customerSERCLI"];
    $customerSERNUM = $_GET["customerSERNUM"];
    $customerSERSRN = $_GET["customerSERSRN"];
    $customerSERMOD = $_GET["customerSERMOD"];
    $customerSERNSP = $_GET["customerSERNSP"];
    $customerSERPRO = $_GET["customerSERPRO"];
    $customerSERVRS = $_GET["customerSERVRS"];

    /* Il controllo viene passato ad un altro script PHP per l'aggiornamento dati cliente */
    print '<h1>Edit an Employee record:</h1>';




    Print 'Server cliente. . . . . . . . . . .'.$customerSERCLI.' '.$customerSERNUM.'
    ';
    Print 'S/N server/Mod./Sist-Part. '.$customerSERSRN.' '.$customerSERNSP.' '.$customerSERMOD.'
    ';
    Print 'Prodotto/Versione. . . . . . . '.$customerSERPRO.' '.$customerSERVRS.'
    ';

    print 'Richiesta effettuata il. . . . . . <input type="text" name="customerSRVDAT">
    ';
    print 'Ora richiesta. . . . . . . . . . . .<input type="text" name="customerSRVORA">
    ';
    print 'Richiesta effettuata da. . . . .<input type="text" name="customerSRVPER">
    ';
    print 'Motivo della chiamata. . . . .<input type="text" name="customerSRVMOT">
    ';
    print '

    ';

    print '<form action="db2_update7.php" method="GET">';
    print '<input type="submit" name="action" value="Server clienti" /></form>';

    print '<form action="db2_update1.php" method="POST">';
    print '<input type="submit" name="action" value="Back " /></form>';

    print '<form action="db2_update4.php" method="POST">';
    print '<input type="submit" name="close" value="Close " /></form>';

    print '<form action="db2_update8.php?customerSRVCLI=' . $customerSERCLI .'
    &customerSRVNUM=' . $customerSERNUM . '&customerSRVSRN=' . $customerSERSRN . '
    &customerSRVMOD=' . $customerSERNSP . '&customerSRVNSP=' . $customerSERMOD . '
    &customerSRVPRO=' . $customerSERPRO . '&customerSRVVER=' . $customerSERVRS . '
    " method="POST">';
    print '<input type="submit" name="action" value="Insert " /></form>';



    print '</form>';




    ?>

    </body>
    </html>




    PAGINA 2 update8 (chiamato)

    <html>
    <?php
    define("PAGE_TITLE", "Customer Update");
    define("PHP_FILE_NAME", "db2_update3.php")
    ?>

    <title><?= PAGE_TITLE . " - " . PHP_FILE_NAME; ?></title>
    <body>
    <?php




    /* Apertura connessione al database*/
    include("connection.inc");

    /* Reperimento variabile passata dal chiamante con il metodo GET */
    $customerSRVCLI = $_GET["customerSRVCLI"];
    $customerSRVNUM = $_GET["customerSRVNUM"];


    /* Reperimento variabili passate dal chiamante con il metodo POST */
    $customerSRVCLI = $_POST["customerSRVCLI"];
    $customerSRVNUM = $_POST["customerSRVNUM"];
    $customerSRVNSP = $_POST["customerSRVNSP"];
    $customerSRVMOD = $_POST["customerSRVMOD"];
    $customerSRVSRN = $_POST["customerSRVSRN"];
    $customerSRVPRO = $_POST["customerSRVPRO"];
    $customerSRVVER = $_POST["customerSRVVER"];

    $customerSRVDAT = $_POST["customerSRVDAT"];
    $customerSRVORA = $_POST["customerSRVORA"];
    $customerSRVPER = $_POST["customerSRVPER"];
    $customerSRVMOT = $_POST["customerSRVMOT"];


    /* Costruzione dello statement SQL da eseguire */

    $sql = "
    insert into ACSSI_DAT.SRVRQ00F

    (SRVATV,SRVNRA,SRVMAN,SRVDUM,SRVDIM,SRVUTM,SRVUTG, SRVCLI,SRVNUM,SRVPRO,SRVVER,SRVSRN,SRVMOD,
    SRVNSP,SRVVOD,SRVVOM,SRVVIS,SRVPER,SRVDAT,SRVORA,S RVMOT,SRVCAS,SRVSOL,SRVUSR,SRVPRR,SRVVRR,
    SRVODR,SRVOMR,SRVDAR,SRVF01,SRVF02,SRVF03,SRVF04,S RVF05,SRVDAI,SRVORI,SRVDAF,SRVORF,SRVDUR,
    SRVWEK,SRVREL,SRVASP,SRVBLD,SRVPAT)

    values
    (' ','0',' ','2006-12-30','2006-12-30','web','web',
    '$customerSRVCLI','$customerSRVNUM','$customerSRVP RO','$customerSRVVER','$customerSRVSRN',
    '$customerSRVMOD','1.1','1.2','codvid','Guarnieri' ,'2006-12-30','00.00.00','Prova MOTIVO',
    'S','SOLUZIONE','Guarnieri','RIC','1.1','1.2','1.3 ','2006-12-31','','','','','','2006-12-31',
    '00.00.00','2006-12-31','00.00.00','10','20','01','02','03','PATCH') ";


    /* Esecuzione diretta dello stament SQL */
    $result = db2_exec($dbh, $sql);

    /* Errore nell'aggiornamento dati cliente */
    if (!$result) {
    print '

    There was a problem updating the user into the database.</p>';
    print '

    Echo of dynamically-built sql:
    '.$sql.'</p>';

    print '&customerSRVMOD';




    } else {

    /* Aggiornamento dati cliente eseguito con successo */

    header("refresh:0 url=db2_update1.php");

    }


    ?>



    </body>
    </html>




    Grazie, ciao

  2. #2
    Utente di HTML.it
    Registrato dal
    Aug 2006
    Messaggi
    833
    up

  3. #3
    Utente di HTML.it L'avatar di luca200
    Registrato dal
    Apr 2002
    Messaggi
    4,120
    Non ho approfondito sulla insert (e tu non hai detto in che senso non funziona), ma l'altro problema è semplice.
    Tu hai dichiarato nel form il metodo post, ma poi metti tutte le variabili sulla action in querystring, mentre il modulo non contiene alcun campo. In questo modo tutte le variabili arrivano comunque in get.
    Se vuoi che arrivino in post devi metterle nel form come campi hidden.

  4. #4
    Utente di HTML.it
    Registrato dal
    Aug 2006
    Messaggi
    833
    mi fai un esempio con uno dei campi in modo da copiarlo? grazie

  5. #5
    Utente di HTML.it
    Registrato dal
    Aug 2006
    Messaggi
    833
    Hai ragione non avevo capito io!!!

    Grazie

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.