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
E fin qui vā tutto bene. Se il login č corretto mi apre una chat fatta da me. La mia intenzione č quella che quando scrivo i messaggio in chat venga visualizzato il nick con cui ho fatto il login. Ora per far riconoscere un nick all' interno della chat ho fatto cosi...
ho creato questa tabella
CREATE TABLE `chat` (
`TIME` TEXT NOT NULL ,
`UTENTE` TEXT NOT NULL ,
`POST` TEXT NOT NULL
);
la chat in questione č
<?php
include 'config2.php'
?>
</head>
<body>
<script>apertura_pagina();</script>
<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 "".$result['UTENTE']." : ".$result['POST']."
" ;
}
?>
</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> ";
}
?>
e nella pagina di chat un input in js. Come posso far in modo che mi riconosce il nick con cui ho fatto il login?? Grazie a chi mi aiuta!

Rispondi quotando