Pagina 2 di 3 primaprima 1 2 3 ultimoultimo
Visualizzazione dei risultati da 11 a 20 su 25

Discussione: controllo form

  1. #11
    Incredibile ragazzi, ancora niente... non ne vuol sapere.. ora vi posto l'intera pagina e vediamo di capirne qualcosa di più:
    Codice PHP:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
    <html>
    <head>
      <link href=stili.css type=text/css rel=stylesheet></link>
      <title>Entrata</title>
      <script type="text/javascript"> 
            
            function soloN(obj) {
                v = obj.value.replace(/[^0-9\.]/g,"");
                obj.value = v;}
            
            [b]function testkm(){
                km_in=document.getElementsById("km_in").value;
                km_out=document.getElementsById("km_out").value;
                            if (km_in<km_out){
                alert("ATTENZIONE! Inserire Kilometraggio maggiore di ("km_out"));  
            return false;}}    [/b]
      
      </script>
    </head> 
    <body>
    <?php
    $host
    ="localhost";
    $username="root";
    $password="";
    $database="vetture";

    $conn=mysql_connect($host,$username,$password);
    mysql_select_db($database) or die("Impossibile selezionare il database");
     
    if(
    $_POST && isset($_GET['id']))
    {
    aggiorna_record();}
    elseif(isset(
    $_GET['id']))
    {
    mostra_record();}
    else
        
    mostra_lista();
     
    function 
    mostra_lista()
    {
        if(isset(
    $_GET['msg']))
            echo 
    '[b]'.htmlentities($_GET['msg']).'[/b]

    '
    ;

        
    $query "SELECT id,data_out,ora_out,vettura,telaio,km_out,km_in,diff_km,targa,autista,passeggero,sorvegliante,note,data_in, ora_in FROM vetture";
        
    $result mysql_query($query);
        if (!
    $result) {
            die(
    "Errore nella query $query: " mysql_error());
        }
        echo 
    '
        <div class="scroller" style="margin:auto"><table border="1">
            <tr>
                <th>Id</th>
                <th>Data Uscita</th>
                <th>Ora Uscita</th>
                <th>Vettura</th>
                <th>Telaio</th>
                <th>Km_out</th>
                <th>Km_in</th>
                <th>Diff_Km</th>
                <th>Targa</th>
                <th>Autista</th>
                <th>Passeggero</th>
                <th>Sorvegliante</th>
                <th>Note</th>
                <th>Data Entrata</th>
                <th>Ora Entrata</th>
                <th></th>
            </tr>'
    ;
         while (
    $row mysql_fetch_assoc($result))
        {
            
    $id=htmlspecialchars($row['id']);
            
    $data_out=htmlspecialchars($row['data_out']);
            
    $ora_out=htmlspecialchars($row['ora_out']);
            
    $vettura=htmlspecialchars($row['vettura']);
            
    $telaio=htmlspecialchars($row['telaio']);
            
    $km_out=htmlspecialchars($row['km_out']);
            
    $km_in=htmlspecialchars($row['km_in']);
            
    $diff_km=htmlspecialchars($row['diff_km']);
            
    $targa=htmlspecialchars($row['targa']);
            
    $autista=htmlspecialchars($row['autista']);
            
    $passeggero=htmlspecialchars($row['passeggero']);
            
    $sorvegliante=htmlspecialchars($row['sorvegliante']);
            
    $note=htmlspecialchars($row['note']);
            
    $data_in=htmlspecialchars($row['data_in']);
            
    $ora_in=htmlspecialchars($row['ora_in']);
            
    $link $_SERVER['PHP_SELF'] . '?id=' $row['id'];
     
            echo 
    "<tr>
                    <td>
    $id</td>
                    <td>
    $data_out</td>
                    <td>
    $ora_out</td>
                    <td>
    $vettura</td>
                    <td>
    $telaio</td>
                    <td>
    $km_out</td>
                    <td>
    $km_in</td>
                    <td>
    $diff_km</td>
                    <td>
    $targa</td>
                    <td>
    $autista</td>
                    <td>
    $passeggero</td>
                    <td>
    $sorvegliante</td>
                    <td>
    $note</td>
                    <td>
    $data_in</td>
                    <td>
    $ora_in</td>
                    <td><a href=\"
    $link\">modifica</a></td>
                </tr>"
    ;
        }
        echo 
    '</table></div>';
        
    mysql_free_result($result);
        
    mysql_close();
    }


    function 
    mostra_record()

        
    $id intval($_GET['id']);
        
    $query "SELECT id,data_out,ora_out,vettura,telaio,km_out,km_in,diff_km,targa,autista,passeggero,sorvegliante,note,data_in,ora_in FROM vetture WHERE id=$id";
        
    $result mysql_query($query);
        if (!
    $result
        { die(
    "Errore nella query $query: " mysql_error()); }
        
        if(
    mysql_num_rows($result) != 1
        { die(
    "l'ID passato via GET è errato"); }
     
        list(
    $id,$data_out,$ora_out,$vettura,$telaio,$km_out,$km_in,$diff_km,$targa,$autista,$passeggero,$sorvegliante,$note,$data_in,$ora_in)=mysql_fetch_row($result);
     
        
    $id=htmlspecialchars($id);
        
    $data_out=htmlspecialchars($data_out);
        
    $ora_out=htmlspecialchars($ora_out);
        
    $vettura=htmlspecialchars($vettura);  
        
    $telaio=htmlspecialchars($telaio);
        
    $km_out=htmlspecialchars($km_out);
        
    $km_in=htmlspecialchars($km_in);
        
    $diff_km=htmlspecialchars($diff_km);
        
    $targa=htmlspecialchars($targa);
        
    $autista=htmlspecialchars($autista);
        
    $passeggero=htmlspecialchars($passeggero);
        
    $sorvegliante=htmlspecialchars($sorvegliante);
        
    $note=htmlspecialchars($note);
        
    $data_in=htmlspecialchars($data_in);
        
    $ora_in=htmlspecialchars($ora_in);    

     echo 
    "  
          <form action=\"test2.php?id=
    $id\" method=\"post\" onsubmit=\"return testkm()\">  
          <table width='20%' align='center' border='1' colspan='2' bgcolor='#000000'>
          <td style='font size:14pt'>[b]DATA USCITA[/b]</td>
          <td style='font size:14pt'><input type='text' name='data_out' size=50 maxlength=40 alt='data_out' align='left' value=\"
    $data_out\"</td><tr>
          <td style='font size:14pt'>[b]ORA USCITA[/b]</td>
          <td style='font size:14pt'><input type='text' name='ora_out' size=50 maxlength=40 alt='ora_out' align='left' value=\"
    $ora_out\"</td><tr>
          <td style='font size:14pt'>[b]VETTURA</td>[/b]</td>
          <td style='font size:14pt'><input type='text' name='vettura' size=50 maxlength=16 alt='vettura' align='left' value=\"
    $vettura\"</td><tr>
          <td style='font size:14pt'>[b]TELAIO[/b]</td>
          <td style='font size:14pt'><input type='text' name='telaio' size=50 maxlength=40 alt='telaio' align='left' value=\"
    $telaio\"</td><tr>
          [b]<td style='font size:14pt'>[b]KM USCITA[/b]</td>
          <td style='font size:14pt'><input type='text' name='km_out' size=50 maxlength=40 alt='km_out' align='left' value=\"
    $km_out\"</td><tr>
          <td style='font size:14pt'>[b]KM ENTRATA[/b]</td>
          <td style='font size:14pt'><input type='text' name='km_in' onkeyup=soloN(this) onblur=soloN(this) size=50 maxlength=40 alt='km_in' align='left' value=\"
    $km_in\"</td><tr>[/b]
          <td style='font size:14pt'>[b]DIFF. KM[/b]</td>
          <td style='font size:14pt'><input type='text' name='diff_km' size=50 maxlength=40 alt='diff_km' align='left' value=\"
    $diff_km\"</td><tr>
          <td style='font size:14pt'>[b]TARGA[/b]</td>
          <td style='font size:14pt'><input type='text' name='targa' size=50 maxlength=7 alt='targa' align='left' value=\"
    $targa\"</td><tr>
          <td style='font size:14pt'>[b]AUTISTA[/b]</td>
          <td style='font size:14pt'><input type='text' name='autista' size=50 maxlength=16 alt='autista' align='left' value=\"
    $autista\"</td><tr>
          <td style='font size:14pt'>[b]PASSEGGERO</td>[/b]</td>
          <td style='font size:14pt'><input type='text' name='passeggero' size=50 maxlength=16 alt='passeggero' align='left' value=\"
    $passeggero\"</td><tr>
          <td style='font size:14pt'>[b]NOTE[/b]</td>
          <td style='font size:14pt'><textarea name='note' rows=\"5\" cols=\"31\" align=\'left\' value=\"
    $note\">$note</textarea></td><tr>
          <td style='font size:14pt'>[b]SORVEGLIANTE[/b]</td>
          <td style='font size:14pt'><input type='text' name='sorvegliante' size=50 maxlenght=20 alt='sorvegliante' align='left' value=\"
    $sorvegliante\"></td><tr>
          "
    ;
    }
    ?> 
          <td style='font size:14pt'>[b]DATA ENTRATA[/b]</td>
          <td style='font size:14pt'><input type='text' name='data_in' size=50 maxlength=40 alt='data_in' align='left' value=<?php echo date("Y/m/d")?>></td><tr>
          <td style='font size:14pt'>[b]ORA ENTRATA[/b]</td>
          <td style='font size:14pt'><input type='text' name='ora_in' size=50 maxlength=40 alt='ora_in' align='left' value=<?php echo date("G:i:s")?>></td><tr>   
          [b]<td><input name='invia' type='submit' align=\'center\' value='Invia'/></td></tr>[/b]  
          </form>
          </table>
          <hr></hr>
          <form action="login_success.php">
          <td align="center"><input type="submit" value="Torna al men&uacute"></td></form>
          </table></div></body>
    </html>
    By GeddY_LeE

  2. #12
    Moderatore di Annunci siti web, Offro lavoro/collaborazione, Cerco lavoro L'avatar di cavicchiandrea
    Registrato dal
    Aug 2001
    Messaggi
    26,133
    In futuro posta la pagina come la riceve il browser cioè html non php, in questo modo forse avresti capito che prima apri il form poi il table ma lo chiudi male
    codice:
    <form action=\"test2.php?id=$id\" method=\"post\" onsubmit=\"return testkm()\">  
          <table width='20%'....
    </form>
          </table>
    in oltre hai due form nella pagina e non sono nominati potresti avere problemi.
    Cavicchi Andrea
    Problemi con javascript, jquery, ajax clicca qui

  3. #13
    Utente di HTML.it L'avatar di abellos
    Registrato dal
    Feb 2002
    Messaggi
    431
    qui manca la chiusura del tag input
    codice:
    <td style='font size:14pt'><input type='text' name='km_in' onkeyup=soloN(this) onblur=soloN(this) size=50 maxlength=40 alt='km_in' align='left' value=\"$km_in\" ></td><tr>
    se provi a correggere secondo me funziona
    Da un grande potere derivano grandi responsabilità

  4. #14
    Moderatore di Annunci siti web, Offro lavoro/collaborazione, Cerco lavoro L'avatar di cavicchiandrea
    Registrato dal
    Aug 2001
    Messaggi
    26,133
    E anche il campo km_out ha lo stesso problema di chiusura >, un disastro nello sviluppo php
    Cavicchi Andrea
    Problemi con javascript, jquery, ajax clicca qui

  5. #15
    pure avendo apportate le modifiche e miglioramenti da voi suggeriti, la situazione non si risolve... vuol'essere ke ci sono 2 form? :O

    Codice PHP:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
    <html>
    <head>
      <link href=stili.css type=text/css rel=stylesheet></link>
      <title>Entrata</title>
      <script type="text/javascript"> 
            
            function soloN(obj) {
                v = obj.value.replace(/[^0-9\.]/g,"");
                obj.value = v;}
            
            function testkm(){
                km_in=document.getElementsById("km_in").value;
                km_out=document.getElementsById("km_out").value;
                            if (km_in<km_out){
                alert("ATTENZIONE! Inserire Kilometraggio maggiore di ("km_out"));  
            return false;}}    
      
      </script>
    </head> 
    <body>
    <?php
    $host
    ="localhost";
    $username="root";
    $password="";
    $database="vetture";

    $conn=mysql_connect($host,$username,$password);
    mysql_select_db($database) or die("Impossibile selezionare il database");
     
    if(
    $_POST && isset($_GET['id']))
    {
    aggiorna_record();}
    elseif(isset(
    $_GET['id']))
    {
    mostra_record();}
    else
        
    mostra_lista();
     
    function 
    mostra_lista()
    {
        if(isset(
    $_GET['msg']))
            echo 
    '[b]'.htmlentities($_GET['msg']).'[/b]

    '
    ;

        
    $query "SELECT id,data_out,ora_out,vettura,telaio,km_out,km_in,diff_km,targa,autista,passeggero,sorvegliante,note,data_in, ora_in FROM vetture";
        
    $result mysql_query($query);
        if (!
    $result) {
            die(
    "Errore nella query $query: " mysql_error());
        }
        echo 
    '
        <div class="scroller" style="margin:auto"><table border="1">
            <tr>
                <th>Id</th>
                <th>Data Uscita</th>
                <th>Ora Uscita</th>
                <th>Vettura</th>
                <th>Telaio</th>
                <th>Km_out</th>
                <th>Km_in</th>
                <th>Diff_Km</th>
                <th>Targa</th>
                <th>Autista</th>
                <th>Passeggero</th>
                <th>Sorvegliante</th>
                <th>Note</th>
                <th>Data Entrata</th>
                <th>Ora Entrata</th>
                <th></th>
            </tr>'
    ;
         while (
    $row mysql_fetch_assoc($result))
        {
            
    $id=htmlspecialchars($row['id']);
            
    $data_out=htmlspecialchars($row['data_out']);
            
    $ora_out=htmlspecialchars($row['ora_out']);
            
    $vettura=htmlspecialchars($row['vettura']);
            
    $telaio=htmlspecialchars($row['telaio']);
            
    $km_out=htmlspecialchars($row['km_out']);
            
    $km_in=htmlspecialchars($row['km_in']);
            
    $diff_km=htmlspecialchars($row['diff_km']);
            
    $targa=htmlspecialchars($row['targa']);
            
    $autista=htmlspecialchars($row['autista']);
            
    $passeggero=htmlspecialchars($row['passeggero']);
            
    $sorvegliante=htmlspecialchars($row['sorvegliante']);
            
    $note=htmlspecialchars($row['note']);
            
    $data_in=htmlspecialchars($row['data_in']);
            
    $ora_in=htmlspecialchars($row['ora_in']);
            
    $link $_SERVER['PHP_SELF'] . '?id=' $row['id'];
     
            echo 
    "<tr>
                    <td>
    $id</td>
                    <td>
    $data_out</td>
                    <td>
    $ora_out</td>
                    <td>
    $vettura</td>
                    <td>
    $telaio</td>
                    <td>
    $km_out</td>
                    <td>
    $km_in</td>
                    <td>
    $diff_km</td>
                    <td>
    $targa</td>
                    <td>
    $autista</td>
                    <td>
    $passeggero</td>
                    <td>
    $sorvegliante</td>
                    <td>
    $note</td>
                    <td>
    $data_in</td>
                    <td>
    $ora_in</td>
                    <td><a href=\"
    $link\">modifica</a></td>
                </tr>"
    ;
        }
        echo 
    '</table></div>';
        
    mysql_free_result($result);
        
    mysql_close();
    }


    function 
    mostra_record()

        
    $id intval($_GET['id']);
        
    $query "SELECT id,data_out,ora_out,vettura,telaio,km_out,km_in,diff_km,targa,autista,passeggero,sorvegliante,note,data_in,ora_in FROM vetture WHERE id=$id";
        
    $result mysql_query($query);
        if (!
    $result
        { die(
    "Errore nella query $query: " mysql_error()); }
        
        if(
    mysql_num_rows($result) != 1
        { die(
    "l'ID passato via GET è errato"); }
     
        list(
    $id,$data_out,$ora_out,$vettura,$telaio,$km_out,$km_in,$diff_km,$targa,$autista,$passeggero,$sorvegliante,$note,$data_in,$ora_in)=mysql_fetch_row($result);
     
        
    $id=htmlspecialchars($id);
        
    $data_out=htmlspecialchars($data_out);
        
    $ora_out=htmlspecialchars($ora_out);
        
    $vettura=htmlspecialchars($vettura);  
        
    $telaio=htmlspecialchars($telaio);
        
    $km_out=htmlspecialchars($km_out);
        
    $km_in=htmlspecialchars($km_in);
        
    $diff_km=htmlspecialchars($diff_km);
        
    $targa=htmlspecialchars($targa);
        
    $autista=htmlspecialchars($autista);
        
    $passeggero=htmlspecialchars($passeggero);
        
    $sorvegliante=htmlspecialchars($sorvegliante);
        
    $note=htmlspecialchars($note);
        
    $data_in=htmlspecialchars($data_in);
        
    $ora_in=htmlspecialchars($ora_in);    

     echo 
    "  
          <form action=\"test2.php?id=
    $id\" method=\"post\" onsubmit=\"return testkm()\">  
          <table width='20%' align='center' border='1' colspan='2' bgcolor='#000000'>
          <td style='font size:14pt'>[b]DATA USCITA[/b]</td>
          <td style='font size:14pt'><input type='text' name='data_out' size=50 maxlength=40 alt='data_out' align='left' value=\"
    $data_out\"></input></td><tr>
          <td style='font size:14pt'>[b]ORA USCITA[/b]</td>
          <td style='font size:14pt'><input type='text' name='ora_out' size=50 maxlength=40 alt='ora_out' align='left' value=\"
    $ora_out\"></input></td><tr>
          <td style='font size:14pt'>[b]VETTURA</td>[/b]</td>
          <td style='font size:14pt'><input type='text' name='vettura' size=50 maxlength=16 alt='vettura' align='left' value=\"
    $vettura\"></input></td><tr>
          <td style='font size:14pt'>[b]TELAIO[/b]</td>
          <td style='font size:14pt'><input type='text' name='telaio' size=50 maxlength=40 alt='telaio' align='left' value=\"
    $telaio\"></input></td><tr>
          <td style='font size:14pt'>[b]KM USCITA[/b]</td>
          <td style='font size:14pt'><input type='text' name='km_out' size=50 maxlength=40 alt='km_out' align='left' value=\"
    $km_out\"></input></td><tr>
          <td style='font size:14pt'>[b]KM ENTRATA[/b]</td>
          <td style='font size:14pt'><input type='text' name='km_in' onkeyup=soloN(this) onblur=soloN(this) size=50 maxlength=40 alt='km_in' align='left' value=\"
    $km_in\"></input></td><tr>
          <td style='font size:14pt'>[b]DIFF. KM[/b]</td>
          <td style='font size:14pt'><input type='text' name='diff_km' size=50 maxlength=40 alt='diff_km' align='left' value=\"
    $diff_km\"></input></td><tr>
          <td style='font size:14pt'>[b]TARGA[/b]</td>
          <td style='font size:14pt'><input type='text' name='targa' size=50 maxlength=7 alt='targa' align='left' value=\"
    $targa\"></input></td><tr>
          <td style='font size:14pt'>[b]AUTISTA[/b]</td>
          <td style='font size:14pt'><input type='text' name='autista' size=50 maxlength=16 alt='autista' align='left' value=\"
    $autista\"></input></td><tr>
          <td style='font size:14pt'>[b]PASSEGGERO</td>[/b]</td>
          <td style='font size:14pt'><input type='text' name='passeggero' size=50 maxlength=16 alt='passeggero' align='left' value=\"
    $passeggero\"></input></td><tr>
          <td style='font size:14pt'>[b]NOTE[/b]</td>
          <td style='font size:14pt'><textarea name='note' rows=\"5\" cols=\"31\" align=\'left\' value=\"
    $note\">$note</textarea></td><tr>
          <td style='font size:14pt'>[b]SORVEGLIANTE[/b]</td>
          <td style='font size:14pt'><input type='text' name='sorvegliante' size=50 maxlenght=20 alt='sorvegliante' align='left' value=\"
    $sorvegliante\"></input></td><tr>
          "
    ;
    }
    ?> 
          <td style='font size:14pt'>[b]DATA ENTRATA[/b]</td>
          <td style='font size:14pt'><input type='text' name='data_in' size=50 maxlength=40 alt='data_in' align='left' value=<?php echo date("Y/m/d")?>></input></td><tr>
          <td style='font size:14pt'>[b]ORA ENTRATA[/b]</td>
          <td style='font size:14pt'><input type='text' name='ora_in' size=50 maxlength=40 alt='ora_in' align='left' value=<?php echo date("G:i:s")?>></input></td><tr>   
          <td><input name='invia' type='submit' align=\'center\' value='Invia'></input></td></tr>  
          </table>
          </form>
          <hr></hr>
          <form action="login_success.php">
          <td align="center"><input type="submit" value="Torna al men&uacute"></input></td></form>
          </table></div></body>
    </html>
    By GeddY_LeE

  6. #16
    Moderatore di Annunci siti web, Offro lavoro/collaborazione, Cerco lavoro L'avatar di cavicchiandrea
    Registrato dal
    Aug 2001
    Messaggi
    26,133
    A) Se ti si chiede di non postare codice php, è meglio accondiscendere, ti ricordo che il problema è il tuo.
    B) E un po d'iniziativa non guasta, hai due form non nominati (come già sottolineato) potrebbero dare problemi provi (momentaneamente) ad eliminarne uno o a nominarli se si risolve bene altrimenti si cerca altre strade
    Ricordati che iniziative, prove, tentativi, non fanno alcun danno, al massimo non funzionano, il pc non esplode, il webserver non si fonde, etc...
    Ti auro di risolvere
    Cavicchi Andrea
    Problemi con javascript, jquery, ajax clicca qui

  7. #17
    Utente di HTML.it L'avatar di abellos
    Registrato dal
    Feb 2002
    Messaggi
    431
    qui non va bene
    codice:
            alert("ATTENZIONE! Inserire Kilometraggio maggiore di ("km_out"));
    va messo cosi per agganciare la stringa alla variabile
    codice:
            alert("ATTENZIONE! Inserire Kilometraggio maggiore di ("+km_out+")");
    Da un grande potere derivano grandi responsabilità

  8. #18
    Mi scuso per aver postato il codice PHP ma me ne ero compeltamente dimenticato

    ho provato anche come suggerito da abellos:
    alert("ATTENZIONE! Inserire Kilometraggio maggiore di ("+km_out+")");
    ma ancora nada...
    Comunque non ho capito come devo fare per nominare i form... :/
    By GeddY_LeE

  9. #19
    Moderatore di Annunci siti web, Offro lavoro/collaborazione, Cerco lavoro L'avatar di cavicchiandrea
    Registrato dal
    Aug 2001
    Messaggi
    26,133
    Originariamente inviato da GeddY_LeE
    Mi scuso per aver postato il codice PHP ma me ne ero compeltamente dimenticato

    ho provato anche come suggerito da abellos:


    ma ancora nada...
    Comunque non ho capito come devo fare per nominare i form... :/
    Menù in alto sezione siti, trovi tutte le guide, per apprendere i rudimenti di html, php, javascript, etc...
    Cavicchi Andrea
    Problemi con javascript, jquery, ajax clicca qui

  10. #20
    [QUOTE]
    [QUOTE]<form name="datiUtenti" style="border:0px"action="paginaRisposta.php">

    Come si può vedere, "name" serve per indicare il nome del form, "action" indica l'URL del programma o della pagina dirisposta che processerà i dati.
    Trovato!

    però... bhò... non capisco il form del submit per tornare alla home funge, il controllo sempre nell'input km_in per far inserire solo e nient'altro che numeri funziona... solo questo per il controllo dell'inserimento di un valore ne minore ne uguale rispetto a km_out mi sta dando un casino di problemi... :O sarebbe un macello ke un ipotetico parcheggiattore, inserisca un kilometraggio inferiore a quando la macchina è uscita xD (forse si sarà fatto la strada in retromarcia) ahah!
    By GeddY_LeE

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.