Pagina 1 di 3 1 2 3 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 21
  1. #1

    Eliminare la richiesta di inserimento nickname in una chat

    ciao io ho una chat che al momento del login mi chiede di inserire sia il nickname che la password, io invece volgio che nel login mi chieda solo la password e che il nikcname me lo metta poi una volta entrato in chat automaticamente senza che lo devo mettere io sul login:

    vi posto i codici di chat.php e login.php e messaggi.php

    chat.php:
    Codice PHP:
    <html>
    <head>
    <title>Happy Chat</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <script language = "JavaScript">
    function textCounter(field, countfield, maxlimit) {
       if(field.value.length > maxlimit){
          field.value = field.value.substring(0, maxlimit);
       }
       else{ 
          countfield.value = maxlimit - field.value.length;
       }
    }
    </script>
    <script language="javascript">
      function aggiungi(y)
      {
      espressione=document.form_ins.messaggio.value;
      new_espressione=espressione + y;
      document.form_ins.messaggio.value=new_espressione;
      }
      </script>
    <style>
    .stile  {
            background:#FFFFFF;
            font-family:verdana;
            font-size:8pt; 
            SCROLLBAR-BASE-COLOR: #0099CC;
            SCROLLBAR-ARROW-COLOR: #FFFFFF;
            }
    </style>
    </head>

    <body bgcolor="#FBBEAA">
    <?
    include("config.php");

    $nick=$_GET['nick'];
    $nick=strtolower($nick);
    $nick=stripslashes($nick);
    $password=$_GET['password'];
    $password=strtolower($password);
    $password_cr=crypt($password,$nick);
    $password_cr=str_replace("|","*",$password_cr);



    if (!(
    file_exists($file_reg)))
    {
    fopen($file_reg,"w");}

    $utente=$nick."|".$password;
    $utente_ok=0;
    $ut_regist=file($file_reg);
    $dim_reg=count($ut_regist);
    for (
    $i=0;$i<$dim_reg;$i++)
    {
    $dati_ut=explode("|",$ut_regist[$i]);
    $nick_ut=$dati_ut[0];
    $pass_ut=$dati_ut[1];
    if ((
    $nick==$nick_ut) & ($password_cr==$pass_ut)) $utente_ok=1;
    }

    if (
    $utente_ok==1)
    {
    if (!(
    file_exists($file_online)))
    {
    fopen($file_online,"w");}

    $dim_file=filesize($file_online);
    $dim_max=14000// Dimensione in bytes massima per ricreare il file online

    if ($dim_file>$dim_max)
    fopen($file_online,"w");

    $ar_orario=getdate();
    $ora=$ar_orario['hours'];
    $minuti=$ar_orario['minutes'];
    $secondi=$ar_orario['seconds'];
    if (
    strlen($minuti)==1$minuti="0".$minuti;
    if (
    strlen($secondi)==1$secondi="0".$secondi;

    $data=date("d/m/Y");
    $orario=$ora.":".$minuti.":".$secondi;
    $utente=$nick."|".$data."|".$orario."\n";

    $ins_online=fopen($file_online,"a+");
    fputs($ins_online,$utente);
    fclose($ins_online);
    }
    else
    {
    echo 
    "<center>[b]E' STATO INSERITO
    UN NICK O UNA PASSWORD
    NON CORRETTI,
    OPPURE NON SEI
    ANCORA REGISTRATO.[/b]

    "
    ;
    echo 
    "<a href=\"javascript:history.back();\">TORNA AL LOGIN</a></center>";
    exit;
    }
    ?>
    <table width="208" align="center" bordercolor="#000000" bgcolor="#E7E9FA" style="border:1px solid;">
            <tr> 
              <td width="208" height="21" colspan="6" bgcolor="#BBC2F2"><div align="center">
    <div align="center"><iframe src="http://www.globalmeteo.altervista.org/chat/messaggi.php" width="200" height="100" scrolling="yes"></iframe> 
        </td></tr></table>


        <div align="center"> 
          
    <table width="208" align="center" bordercolor="#000000" bgcolor="#E7E9FA" style="border:1px solid;">
            <tr> 
              <td width="208" height="21" bgcolor="#BBC2F2"><div align="center"><font color="#000000" size="2" face="Verdana, Arial, Helvetica, sans-serif">[b]PERSONE 
                  ON-LINE [/b]</font></div></td>
            </tr>
            <tr> 
              <td height="21"><iframe width="200" height="50" src="online.php" scrolling="no"></iframe></td>
            </tr>
          </table>
          



    <form method="GET" action="insert.php" name="form_ins" > 

    <table width="208" align="center" bordercolor="#000000" bgcolor="#E7E9FA" style="border:1px solid;">
            <tr> 
              <td width="208" height="21" colspan="6" bgcolor="#BBC2F2"><div align="center"><font color="#000000" size="2" face="Verdana, Arial, Helvetica, sans-serif">[b]SIMBOLI METEO - SMILES[/b]</font></div></td>
            </tr>
        <tr><td colspan="4"><div align="center">
    <? 

    if ( empty($_GET['faccina']) ) $faccina "" 
    else 
    $faccina $_GET['faccina'] ; 

    echo 

    <select name=\"faccina\" size=\"1\"> 

    <option value=\"[em1]\" "

    if ( 
    $faccina == "[em1]" ) echo " selected" 
    echo 
    ">sereno</option> 

    <option value=\"[em2]\" "

    if ( 
    $faccina == "[em2]" ) echo " selected" 
    echo 
    ">poco-nuvoloso</option> 

    <option value=\"[em3]\" "

    if ( 
    $faccina == "[em3]" ) echo " selected" 
    echo 
    ">nuvoloso</option> 

    <option value=\"[em4]\" "

    if ( 
    $faccina == "[em4]" ) echo " selected" 
    echo 
    ">luna</option> 

    <<option value=\"[em5]\" "

    if ( 
    $faccina == "[em5]" ) echo " selected" 
    echo 
    ">luna-nuvoloso</option> 

    <option value=\"[em6]\" "

    if ( 
    $faccina == "[em6]" ) echo " selected" 
    echo 
    ">pioggia</option> 

    <option value=\"[em7]\" "

    if ( 
    $faccina == "[em7]" ) echo " selected" 
    echo 
    ">pioggia-neve</option> 

    <option value=\"[em8]\" "

    if ( 
    $faccina == "[em8]" ) echo " selected" 
    echo 
    ">temporale</option> 

    <option value=\"[em9]\" "

    if ( 
    $faccina == "[em9]" ) echo " selected" 
    echo 
    ">neve</option> 

    <option value=\"[em10]\" "

    if ( 
    $faccina == "[em10]" ) echo " selected" 
    echo 
    ">nebbia</option> 

    </select> 
    "


    ?> </td>            

              <td height="21"><div align="center">[img]emoticons/em11.gif[/img]</div></td>
              <td height="21"><div align="center">[img]emoticons/em12.gif[/img]</div></td></tr>

    <tr> 
              <td height="21"><div align="center">[img]emoticons/em13.gif[/img]</div></td>
              <td height="21"><div align="center">[img]emoticons/em14.gif[/img]</div></td>
              <td height="21"><div align="center">[img]emoticons/em15.gif[/img]</div></td>
              <td height="21"><div align="center">[img]emoticons/em16.gif[/img]</div></td>
              <td height="21"><div align="center">[img]emoticons/em17.gif[/img]</div></td>
              <td height="21"><div align="center">[img]emoticons/em18.gif[/img]</div></td>

            </tr>
          
    </table>
          
     <table width="208" align="center" bordercolor="#000000" bgcolor="#E7E9FA" style="border:1px solid;">
            <tr> 
              <td height="21" bgcolor="#BBC2F2"><div align="center"><font color="#000000" size="2" face="Verdana, Arial, Helvetica, sans-serif">[b]MESSAGGIO[/b]</font></div></td>
            </tr>
            <tr> 
              <td ><form method="GET" action="insert.php" name="form_ins" >
                  <table width="170" border="0" align="center">
                    <tr> 
                      <td colspan="2"><div align="center"> 
                          <textarea rows="3" onKeyDown="textCounter(this.form.messaggio,this.form.rem,400);" onKeyUp="textCounter(this.form.cjmsg,this.form.rem,400);" cols="19" type="text" name="messaggio"></textarea>
                        </div></td>
                    </tr>
                    <tr> 
                      <td><div align="right"><font size="1" face="Verdana, Arial, Helvetica, sans-serif">Lettere 
                          rimaste:</font></div></td>
                      <td><div align="center"> 
                          <input readonly class="stile" type=text name=rem size=3 maxlength=3 value="400">
                        </div></td>
                    </tr>
                    <tr> 
                      <td height="26" colspan="2"> <div align="center"> 
                          <? 
                         
    echo "<input type=\"hidden\" name=\"nick\" value=\"$nick\">";
                         echo 
    "<input type=\"hidden\" name=\"password\" value=\"$password\">" 
                         
    ?>
                          <input type="submit" name="Submit" value="Invia messaggio">
                        


    </div></td>
                    </tr>
                  




    </table>
                </form></td>
            </tr>
          </table>
    </body>
    </html>
    login.php:
    Codice PHP:
    <html>
    <
    head>
    <
    title>Login alla chat</title>
    <
    meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </
    head>

    <
    body bgcolor="#FBBEAA">
    <
    table width="208" align="center" cellpadding="4" bordercolor="#000000" bgcolor="#F8EBC2" style="border:1px solid">
        <
    tr bgcolor="#F0DBAA"
          <
    td colspan="2"
            <
    div align="center"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">[b]BENVENUTI 
              IN CHAT
    [/b]</font></div></td>
        </
    tr>
        <
    tr><td>
    <
    p align="justify">Benvenuti nella chat meteo di Globalmeteoentrando potrete inserire le condizioni meteo 
    attuali inerenti alla vostra città 
    !
    </
    p>
        </
    tr></td></td></table>


    <
    form method="get" action="chat.php">
      <
    table width="208" align="center" cellpadding="4" bordercolor="#000000" bgcolor="#F8EBC2" style="border:1px solid">
        <
    tr bgcolor="#F0DBAA"
          <
    td colspan="2"
            <
    div align="center"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">[b]LOGIN 
              ALLA CHAT
    [/b]</font></div></td>
        </
    tr>
        <
    tr
          <
    td colspan="2"><div align="center"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">---------------------------
    [
    i][b]Se 
              non sei gi
    &agraveregistrato 
    <font color="#000000">>> <a href="http://www.globalmeteo.altervista.org/chat/register.php">clicca 
              qui
    </a> <<[/b][/i][b][/b]</font>
    --------------------------- </
    font></div></td>
        </
    tr>
        <
    tr
          <
    td width="60"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">[b]Nick:[/b]</font></td>
          <
    td><input name="nick" type="text" id="nick" size="14" maxlength="20"></td>
        </
    tr>
        <
    tr
          <
    td><font size="2" face="Verdana, Arial, Helvetica, sans-serif">[b]Password:[/b]</font></td>
          <
    td><input name="password" type="password" id="nick3" size="14" maxlength="20"></td>
        </
    tr>
        <
    tr
          <
    td colspan="2"><div align="center"><input type="submit" name="Submit" value="Entra in chat"></td>
             </
    tr>
      </
    table>
    </
    form>


    <
    div align="center"><a href="http://www.globalmeteo.altervista.org/reg.html">
    <
    font size="2" face="arial">[b]Leggi il regolamento della chat</font>[/b]</a>


    _________________________

    <font size="2" face="arial">Ci sono 23 utenti registrati
    </body>
    </
    html
    e messaggi.php:
    Codice PHP:
    <html>
    <head>
    <title>Messaggi degli utenti</title>
    <?
    include("config.php");
    echo 
    "<meta http-equiv=\"refresh\" content=\"$time_refresh\">";
    ?>
    <script language="javascript">
    function apri(nick_ut)
    {
    window.open("profilo.php?nick=" + nick_ut,nick_ut,"width=500, height=300, left=200");
    }
    </script>


    </head>

    <body>
    <?
    if (!(file_exists($file_mess)))
    {
    fopen($file_mess,"w");}

    $rows_file=file($file_mess);
    $rows_file_ord=array_reverse($rows_file);
    $count=count($rows_file_ord);

    if (
    $count<$num_messag)
    {
    for (
    $i=0;$i<$count;$i++)
    {
    $dati_utente=explode("|",$rows_file_ord[$i]);
    $nick=$dati_utente[0];
    $msg=$dati_utente[1];

    $nick=stripslashes($nick);
    $msg=stripslashes($msg);

    $msg str_replace('[em1]','[img]emoticons/em1.gif[/img]',$msg);

    for (
    $x=1;$x<19;$x++)
    {
    $img="em".$x;
    $img2="[".$img."]";
    $path="<img src=\"emoticons/$img.gif\">";
    $msg str_replace("$img2","$path",$msg);
    }
    echo 
    "[b]<font face=\"verdana\" size=\"2\" color=\"#000000\">$nick</font>: [/b]"."<font face=\"verdana\" size=\"2\">".$msg."</font>
    "
    ;
    }
    }
    else
    {

    for (
    $i=0;$i<$num_messag;$i++)
    {
    $online_ut[$i]=$rows_file_ord[$i];
    $dati_utente=explode("|",$rows_file_ord[$i]);
    $nick=$dati_utente[0];
    $msg=$dati_utente[1];

    $nick=stripslashes($nick);
    $msg=stripslashes($msg);

    for (
    $x=1;$x<19;$x++)
    {
    $img="em".$x;
    $img2="[".$img."]";
    $path="<img src=\"emoticons/$img.gif\">";
    $msg str_replace("$img2","$path",$msg);
    }

    echo 
    "[b]<font face=\"verdana\" size=\"2\"><font face=\"verdana\" size=\"2\" color=\"#000000\">$nick</font>: [/b]"."<font face=\"verdana\" size=\"2\">".$msg."</font>
    "
    ;
    }
    $online_ut=array_reverse($online_ut);
    fopen($file_mess,"w");
    $ins_msg=fopen($file_mess,"a+");
    for (
    $i=0;$i<$num_messag;$i++) fwrite($ins_msg,$online_ut[$i]);
    fclose($ins_msg);
    }
    ?>

    </body>
    </html>
    spero che qualcuno m'aiuti ciao!!!

  2. #2
    Utente di HTML.it L'avatar di dottwatson
    Registrato dal
    Feb 2007
    Messaggi
    3,012
    Codice PHP:

    if (!(file_exists($file_reg)))
    {
    fopen($file_reg,"w");}

    $utente=$nick."|".$password;
    $utente_ok=0;
    $ut_regist=file($file_reg);
    $dim_reg=count($ut_regist);
    for (
    $i=0;$i<$dim_reg;$i++)
    {
    $dati_ut=explode("|",$ut_regist[$i]);
    $nick_ut=$dati_ut[0];
    $pass_ut=$dati_ut[1];
    if ((
    $nick==$nick_ut) & ($password_cr==$pass_ut)) $utente_ok=1
    potresti provare così.... vediamo se ho capito bene il tuo codice

    Codice PHP:

    if (!(file_exists($file_reg)))
    {
    fopen($file_reg,"w");}

    $utente=$nick."|".$password;
    $utente_ok=0;
    $ut_regist=file($file_reg);
    $dim_reg=count($ut_regist);
    for (
    $i=0;$i<$dim_reg;$i++)
    {
    $dati_ut=explode("|",$ut_regist[$i]);
    $nick_ut=$dati_ut[0];
    $pass_ut=$dati_ut[1];
    if (
    $password_cr==$pass_ut
    {
    $utente_ok=1
    $nick=$nick_ut;

    nel form elimina il campo utente e metti <input type="hidden" name="nick" value="auto">

    spero di esserti stato di aiuto
    Non sempre essere l'ultimo è un male... almeno non devi guardarti le spalle

    il mio profilo su PHPClasses e il mio blog laboweb

  3. #3
    innanzitutto ti ringrazio per l'aiuto che però non è andato a buon fine nel senso che mi dà questo errore una volta inserita la password:


    Parse error: syntax error, unexpected $end in /membri/globalmeteo/chat/chat.php on line 236


    spero tu mi dia altre dritte, ciao!

  4. #4
    pensando meglio al tuo aiuto forse ho capito che non sei riuscito bene a comprendere la richiesta, dunque, io nella registrazione alla chat devo inserire un nik che poi mi viene richiesto anche nel login per entrare compresa anche la password, io voglio che mi venga richiesta solo la password e così poi entrato in chat ad ogni messaggio mi compare automaticamente il nik che avevo scelto nella registrazione, ciao!!

  5. #5

  6. #6

  7. #7
    Utente di HTML.it L'avatar di dottwatson
    Registrato dal
    Feb 2007
    Messaggi
    3,012
    eccomi scusa.. ora sono in italia!!! epàààààààà!!!

    mandava una parentesi graffa

    Codice PHP:
    if (!(file_exists($file_reg)))
    {
    fopen($file_reg,"w");}

    $utente=$nick."|".$password;
    $utente_ok=0;
    $ut_regist=file($file_reg);
    $dim_reg=count($ut_regist);
    for (
    $i=0;$i<$dim_reg;$i++)
    {
    $dati_ut=explode("|",$ut_regist[$i]);
    $nick_ut=$dati_ut[0];
    $pass_ut=$dati_ut[1];
    if (
    $password_cr==$pass_ut)
    {
    $utente_ok=1;
    $nick=$nick_ut;
    break;
    }

    Non sempre essere l'ultimo è un male... almeno non devi guardarti le spalle

    il mio profilo su PHPClasses e il mio blog laboweb

  8. #8
    ho corretto come tu hai detto ma mi dice una volta cliccando entra in chat:

    E' STATO INSERITO
    UN NICK O UNA PASSWORD
    NON CORRETTI,
    OPPURE NON SEI
    ANCORA REGISTRATO.

    miseriaccia come si può fare...

  9. #9
    Utente di HTML.it L'avatar di dottwatson
    Registrato dal
    Feb 2007
    Messaggi
    3,012
    Codice PHP:
    $nick=$_GET['nick'];
    $nick=strtolower($nick);
    $nick=stripslashes($nick);
    $password=$_GET['password'];
    $password=strtolower($password);
    $password_cr=crypt($password,$nick);
    $password_cr=str_replace("|","*",$password_cr);

    if (!(
    file_exists($file_reg)))
    {
    fopen($file_reg,"w");}

    $utente=$nick."|".$password;
    $utente_ok=0;
    $ut_regist=file($file_reg);
    $dim_reg=count($ut_regist);
    for (
    $i=0;$i<$dim_reg;$i++)
    {
    $dati_ut=explode("|",$ut_regist[$i]);
    $nick_ut=$dati_ut[0];
    $nick=$nick_ut// qui setti in automatico che $nick è uguale al nick appena letto, quindi DEVE dare TRUE
    $pass_ut=trim($dati_ut[1]);// eliminaimo spazi e fastidiosi ritorni a capo
    if (($nick==$nick_ut) & ($password_cr==$pass_ut)) $utente_ok=1;

    riprova così... è una finezza che poteva dare errore, ma se nn risolvi nenache così c'è qualcos' altro che devo sapere, perchè dovrebbe funzionare

    quello che fa funzionare tutto il resto è

    if (($nick==$nick_ut) & ($password_cr==$pass_ut)) $utente_ok=1;
    Non sempre essere l'ultimo è un male... almeno non devi guardarti le spalle

    il mio profilo su PHPClasses e il mio blog laboweb

  10. #10
    nulla di fatto mi dà sempre lo stesso messaggio, comunque provo a spiegarti meglio cosa voglio fare:

    per entrare in chat come vedi la pagina login mi chiede di inserire il nikname scelto durante la registrazione e anche la password scelta durante la registrazione, i dati vengono inseriti in un file di testo registro.txt (che contiene nik, password, e altri dati dell'utente), io voglio che per entrare in chat mi venga chiesto di digitare solo la password scelta durante la registrazione e non il nikname, spero di essere stato più chiaro possibile, al limite ti aggiungo pure il codice della pagina ins_ut.php

    ins_ut:
    Codice PHP:
    <html>
    <head>
    <title>Registrazione alla chat</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>

    <body bgcolor="#FBBEAA">
    <?
    include("config.php");

    $nick=$_GET['nick'];
    $nick=strtolower($nick);
    $nick=stripslashes($nick);

    $password=$_GET['password'];
    $password=strtolower($password);
    $password_cr=crypt($password,$nick);
    $password_cr=str_replace("|","*",$password_cr);

    $age=$_GET['age'];
    $sex=$_GET['sex'];
    $nation=$_GET['nation'];
    $hobbies=$_GET['hobbies'];



    $nation=stripslashes($nation);
    $hobbies=stripslashes($hobbies);

    if (!(
    file_exists($file_reg)))
    {
    fopen($file_reg,"w");}

    $utente_ok=1;
    $ut_regist=file($file_reg);
    $dim_reg=count($ut_regist);
    for (
    $i=0;$i<$dim_reg;$i++)
    {
    $utente=chop($ut_regist[$i]);
    $dati_ut=explode("|",$utente);
    $nick_ut=$dati_ut[0];
    $pass_ut=$dati_ut[1];
    if ( (
    $nick==$nick_ut) | ($password_cr==$pass_ut) ) $utente_ok=0;
    }

    if (
    $utente_ok==1)
    {
    if (empty(
    $nick) | empty($password) | empty($nation) | empty($sex) | empty($hobbies))
    {
    echo 
    "<center><font face=\"Verdana\" size=\"2\">NON HAI RIEMPITO UNO O PIU' CAMPI</font></center>

    "
    ;
    echo 
    "<center><font face=\"Verdana\" size=\"2\"><a href=\"javascript:history.back();\">TORNA INDIETRO</a></font></center>";
    }
    else
    {
    $utente=$nick."|".$password_cr."|".$age."|".$sex."|".$nation."|".$hobbies."\n";

    $ins_utente=fopen($file_reg,"a+");
    fputs($ins_utente,$utente);
    fclose($ins_utente);

    echo 
    "<center>Sei registrato alla chat.
     <a href=\"login.php\">Vai al login</a></center>"
    ;
    }
    }
    else
    echo 
    "<center>Nick o password già utilizzata.
    <a href=\"javascript:history.back();\">Torna indietro</a><center>"

    ?>
    </body>
    </html>
    spero di riuscire...ciao!

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.