Visualizzazione dei risultati da 1 a 3 su 3
  1. #1

    come informare mancata compilazione campo?

    Ciao,

    Volevo informare l'utente nel caso nn avesse inserito compilato i campi cognome e data arrivo dell' errore attraverso il seguente script, ma ovviamente mi dà errore , innanzi tutto una funzione va immessa prima o dopo il body?
    come faccio a fargli controllare le variabili tipo POST? :rollo:

    grz

    html-php
    <?php
    if (isset($_POST['nome'])){
    include("dati.txt");
    $link = mysql_connect($db_host, $db_login, $db_pass) or die (mysql_error());
    mysql_select_db($database) or die (mysql_error());

    list($giorno, $mese, $anno) = explode('/', $_POST['datarrivo']);
    $datarrivo ="$anno-$mese-$giorno";

    list($giorno2, $mese2, $anno2) = explode('/', $_POST['datapartenza']);
    $datapartenza="$anno2-$mese2-$giorno2";


    $dati = "INSERT INTO prenotazioni VALUES ('', ";
    $dati .= "'" . addslashes($_POST['nome']) . "', ";
    $dati .= "'" . addslashes($_POST['cognome']) . "', ";
    $dati .= "'$datarrivo', ";
    $dati .= "'$datapartenza',";
    $dati .= "'$notti',";
    $dati .= "'" . $_POST['fax'] . "')";
    mysql_query ($dati) or die (mysql_error());
    Header("Location: ". $link_to_redirect);
    }
    ?>

    <html>
    <head>
    <meta name=Proprietà content=prova>
    <meta name=ProgId content=PHP studio>
    <title>Prenotazioni</title>
    </head>
    function check_form($_cognome,$datarrivo) {
    if(!$_cognome,||!$datarrivo):
    print ("<h3>hai dimenticato alcuni campi importanti!"<h3>);
    }
    <body>


    <TABLE border=0 width=100% cellpadding=3>
    <tr>
    <td width=100% colspan=2>
    <p align=center>Inserisci Prenotazione
    <form method=POST action=<? $PATH_INFO ?>>
    </td>
    </tr>

    <tr>
    <td width=18%>Nome</td>
    <td width=82%><input type=text name=nome size=20></td>
    </tr>
    <tr>
    <td width=18%>Cognome</td>
    <td width=82%><input type=text name=cognome size=20></td>
    </tr>
    <tr>
    <td width=18%>Data Arrivo</td>
    <td width=82%><input type=text name=datarrivo size=20></td>
    </tr>
    <tr>
    <td width=18%>Data Partenza</td>
    <td width=82%><input type=text name=datapartenza size=20></td>
    </tr>
    <tr>
    <td width=18%>notti</td>
    <td width=82%><input type=text name=notti size=20></td>
    </tr>
    <tr>
    <td width=18%>fax</td>
    <td width=82%><input type=text name=fax size=20></td>
    </tr>
    <tr>
    <td width=18%>CAP</td>
    <td width=82%><input type=text name=cap size=20></td>
    </tr>
    <tr>
    <td width=18%>Telefono</td>
    <td width=82%><input type=text name=tel size=20></td>
    </tr>
    <tr>
    <td width=18%>Cellulare</td>
    <td width=82%><input type=text name=cell size=20></td>
    </tr>
    <tr>
    <td width=18%><input type=submit value=Inserisci nuovi dati></td>
    <td width=82%></form></td>
    </tr>
    </table>
    </body>
    </html>
    fine
    Php4ever!

  2. #2
    Apparte che è php e non html comunque puoi dare un occhio qui:

    http://forum.html.it/forum/showthrea...hlight=oggetti

    oppure in generale per verificare se è stato compilato un campo utilizzi

    codice:
    if (isset($_POST['bla']))

    una funzione la puoi mettere dove vuoi, le variabili per passare alle funzioni devi richiamarle così:

    codice:
    function chiama($bla, $juk){
    //codice, qui utilizzerai $bla e $juk che avranno rispettivamente i valori di $_POST['buz'] e $_GET['num']
    }
    
    ...
    
    chiama ($_POST['buz'],$_GET['num']);
    GdR Online - http://lenar.it/
    Yesterday is history. Tomorrow is mystery.
    Today is a gift. That's why it's called the present

  3. #3
    ok

    cmq cambiato tr.. grz
    Php4ever!

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.