• User

    Problema con login e database

    Allora, vi spiego la mia situazione. Ho creato un form di registrazione e un form di login.
    Queste sono le tabelle del form di registrazione...

    CREATE TABLE `my_database`.`utenti_temp` (
    `codiceconferma` VARCHAR( 100 ) NOT NULL ,
    `username` VARCHAR( 60 ) NOT NULL ,
    `password` VARCHAR( 100 ) NOT NULL ,
    `email` VARCHAR( 60 ) NOT NULL
    ) ENGINE = MYISAM
    
    CREATE TABLE `my_database`.`utenti` (
    `id` INT NOT NULL AUTO_INCREMENT ,
    `username` VARCHAR( 60 ) NOT NULL ,
    `password` VARCHAR( 100 ) NOT NULL ,
    `email` VARCHAR( 60 ) NOT NULL ,
    PRIMARY KEY ( `id` )
    ) ENGINE = MYISAM
    

    Se il login è corretto mi porta in chat. E fin qui tutto bene.

    ho creato questa tabella per la chat

    CREATE TABLE `chat` (
    `TIME` TEXT NOT NULL ,
    `UTENTE` TEXT NOT NULL ,
    `POST` TEXT NOT NULL
    );
    

    Il problema che io una volta fatto il login i messaggi che scrivo in chat devono essere inviati con il nick con cui ho fatto il login. Per ora c' è un input in javascript. Ecco la chat

    <?php
    include 'config2.php'
    ?>
    </head>
    <body>
    <script>apertura_pagina();</script>
    <br><br><br><br>
    <table border=0 align=center id="tabella" height=200px width=500px>
    <tr>
    <td style="font-size:13px" valign=top>
    <div style="overflow: auto;width: 100%; height: 175px">
    <?php
    
    $query = mysql_query("SELECT * FROM `chat` ORDER BY `TIME` ASC");
    
    while($result = mysql_fetch_array($query)) {
    print "<b>".$result['UTENTE']." : </b> ".$result['POST']." <br>" ;
    }
    ?>
    </div>
    </td>
    </tr>
    <tr>
    <td height=25px style="border-color:grey;">
    <form action="" method="POST" style="margin:0px;padding=0px;">
    <input type="text" name="testo" style="width: 430px; border-style:solid; background-color:grey;" />
    <input type="hidden" name="utente" value="<?php print htmlspecialchars(@$_COOKIE['nome_utente']); ?>" />
    <input type="submit" name="submit" value="INVIA" style="border-style:solid; border-color:black;background-color:grey;" />
    </form>
    </td>
    </tr>
    </table>
    <?php
    if(!empty($_POST['testo']) && !empty($_POST['utente'])) {
    
    $text = mysql_real_escape_string( htmlentities( stripslashes( $_POST['testo'] )));
    $utente = mysql_real_escape_string( htmlentities( stripslashes( $_POST['utente'] )));
    
    mysql_query("INSERT INTO `chat` (`TIME` ,`UTENTE` ,`POST`
    )VALUES (
    NOW( ), '{$utente}', '{$text}');");
    
    print " <script language='JavaScript'>aggiorna()</script> ";
    }
    ?>
    

    Grazie a tutti!