Pagina 1 di 3 1 2 3 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 27

Discussione: Undefined variable

  1. #1
    Utente di HTML.it L'avatar di carlo55
    Registrato dal
    Nov 2002
    residenza
    Padova
    Messaggi
    204

    Undefined variable

    PREMESSA: scusate la mia profonda ignoranza; mi aiutate per cortesia con il seguente script ???

    <?
    if (isset ($_POST['invia']) && $_POST['invia'] == 'ok')
    {
    if ($_POST['nsede'] == "")
    {
    $ok = "false";
    $errore1 = "<font color=\"#FF0000\">- OBBLIGATORIO -</font>\n";
    }
    if ($_POST['nnome'] == "")
    {
    $ok = "false";
    $errore2 = "<font color=\"#FF0000\">- OBBLIGATORIO -</font>\n";
    }
    if ($_POST['mittente'] == "")
    {
    $ok = "false";
    $errore3 = "<font color=\"#FF0000\">- OBBLIGATORIO -</font>\n";
    }
    if ($_POST['mittente'] == "")
    {
    if (!eregi( "^[_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3}$", $_POST['mittente']))
    {
    $errore3 = "<font color=\"#FF0000\">- E-MAIL non corretta -</font>\n";
    $ok = "false";
    }
    }
    //if ($testo_mes == "")
    if ($_POST['testo_mes'] == "")
    {
    $ok= "false";
    $errore4 = "<font color=\"#FF0000\">- OBBLIGATORIO -</font>\n";
    }
    if ($ok != "false")
    {
    mail("xxxxxxx@xxxx.it", "Contatti dal sito del XXXXXXXXXXXXXXXXXX","$testo_mes\n\n---------\nIndirizzo IP: ", "mittente: $nome <$mittente>\nReply-To: $nome <$mittente>\nE-Mail: XXXXXXXXX XXXXXXXXX XXXXXXXX - XXXX\nSender: $nome <$mittente>");
    echo "<font size=\"2\" face=\"Verdana, Arial, Helvetica, sans-serif\">Grazie per aver scritto
    Sarete contattati al più presto
    XXXXXXXXX XXXXXXXXX XXXXXXXX - XXXX</font>\n";
    }
    elseif ($ok == "false")
    {

    ?>

    <form method="POST" action="<? echo "contatti.php" ?>">
    <div align="center">
    <center>
    <table border="0" cellspacing="0" width="350" >
    <tr>
    <td>
    <div align="center">
    <table border="0" cellspacing="0" width="100%" cellpadding="3">
    <tr>
    <td colspan="2">
    <p align="center">CONTATTI</td>
    </tr>
    <tr>
    <td width="50%">
    Sede: <? echo $errore1 ?>

    <input type="text" name="nsede" size="30" tabindex="1" value="<? echo $nsede ?>">

    Cognome Nome: <? echo $errore2 ?>

    <input type="text" name="nnome" size="30" tabindex="2" value="<? echo $nnome ?>">

    E-mail: <? echo $errore3 ?>

    <input type="text" name="mittente" size="30" tabindex="3" value="<? echo $mittente ?>">

    Messaggio: <? echo $errore4 ?>

    <textarea rows="10" name="testo_mes" cols="30" tabindex="4"><? echo $testo_mes ?></textarea>
    <input type="hidden" name="invia" value="ok"></td>
    <td width="50%" valign="bottom">
    <p align="center"><input type="submit" value="INVIA" tabindex="5"></p>
    <p align="center"></p>
    <p align="center"><input type="reset" value="PULISCI" tabindex="6"></td>
    </tr>
    <tr>
    <td width="100%" colspan="2" height="5">
    </td>
    </tr>
    </table>
    </div>
    </td>
    </tr>
    </table>
    </center>
    </div>
    </form>
    <?
    }
    }
    else
    {
    ?>

    <form method="POST" action="<? echo "contatti.php" ?>">
    <div align="center">
    <center>
    <table border="0" cellspacing="0" width="350">
    <tr>
    <td>
    <div align="center">
    <table border="0" cellspacing="0" width="100%"cellpadding="3">
    <tr>
    <td colspan="2">
    <p align="center">CONTATTI</td>
    </tr>
    <tr>
    <td width="50%">
    Sede:

    <input type="text" name="nsede" size="30" tabindex="1">

    Cognome Nome:

    <input type="text" name="nnome" size="30" tabindex="2">

    E-mail

    <input type="text" name="mittente" size="30" tabindex="3">

    Messaggio:

    <textarea rows="10" name="testo_mes" cols="30" tabindex="4"></textarea>

    <input type="hidden" name="invia" value="ok"></td>
    <td width="50%" valign="bottom">
    <p align="center"><input type="submit" value="INVIA" tabindex="5"></p>
    <p align="center"></p>
    <p align="center"><input type="reset" value="PULISCI" tabindex="6"></td>
    </tr>
    <tr>
    <td width="100%" colspan="2" height="5">
    </td>
    </tr>
    </table>
    </div>
    </td>
    </tr>
    </table>
    </center>
    </div>
    </form>
    <?
    }
    ?>

    Mi va tuuto in errore che casino ho combinato
    Grazie
    Restiamo Umani

  2. #2
    Utente bannato
    Registrato dal
    Sep 2005
    Messaggi
    905
    scommetto che ti da: undefinied variable $ok, no? beh è naturale, perva a scrivere male i dati e non ti esce. Uscirtà di sicuro un errore di notice. Fai così:
    codice:
    if ($_POST['nsede'] == "")
    {
    $ok = "false";
    $errore1 = "<font color=\"#FF0000\">- OBBLIGATORIO -</font>\n";
    }
    sostituisci con
    codice:
    $ok = "true";
    if ($_POST['nsede'] == "")
    {
    $ok = "false";
    $errore1 = "<font color=\"#FF0000\">- OBBLIGATORIO -</font>\n";
    }
    dimmi ora

  3. #3
    Utente di HTML.it L'avatar di carlo55
    Registrato dal
    Nov 2002
    residenza
    Padova
    Messaggi
    204
    GRAZIE però non va ancora mi da errore;


    Notice: Undefined variable: nsede in d:\easyphp1-7\www\sindacato\versione_9\prove_varie\contatti.ph p on line 60


    che sarebbe questa:

    <input type="text" name="nsede" size="30" tabindex="1" value="<? echo $nsede ?>">

    Cognome Nome: <? echo $errore2 ?>
    Restiamo Umani

  4. #4
    Utente bannato
    Registrato dal
    Sep 2005
    Messaggi
    905
    al posto di $nsede metti $_POST['nsede'] e così con tutti i campi al di sotto di questa linea.


  5. #5
    if (isset($_POST['nsede']) && $_POST['nsede'] == "")
    Addio Aldo, amico mio... [03/12/70 - 16/08/03]

  6. #6
    Originariamente inviato da gm
    if (isset($_POST['nsede']) && $_POST['nsede'] == "")
    gm...
    cosa cambia se io faccio
    if (isset($_POST['nsede']) & $_POST['nsede'] == "")

    con un solo "&"


    :master:
    Ciao!

  7. #7
    Utente bannato
    Registrato dal
    Sep 2005
    Messaggi
    905
    credo che così sia errore di sintassi, io uso sempre per sicurezza && e non un solo &, al massimo puoi mettere "and"...

  8. #8
    Una sola & indica un operatore bitwise

    http://www.php.net/manual/it/languag...rs.bitwise.php
    Addio Aldo, amico mio... [03/12/70 - 16/08/03]

  9. #9
    Utente di HTML.it L'avatar di carlo55
    Registrato dal
    Nov 2002
    residenza
    Padova
    Messaggi
    204
    Scusatemi ma va sempre in errore


    Notice: Undefined variable: nsede in d:\easyphp1-7\www\sindacato\versione_9\prove_varie\contatti.ph p on line 59



    che sarebbe

    <input type="text" name="nsede" size="30" tabindex="1" value="<? echo $nsede ?>">
    Restiamo Umani

  10. #10
    Utente bannato
    Registrato dal
    Sep 2005
    Messaggi
    905
    ho detto modifica <? echo $nsede ?> con <? echo $_POST['nsede'] ?> modifica!!

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 © 2024 vBulletin Solutions, Inc. All rights reserved.