-
Non riesco a Cookiare
Aiutatemi ragazzi! Sono disperato! Allora il mio problema è questo: voglio far scrivere dentro un'area di testo, un cookie che ricorda il nick, in modo tale da non riscriverlo sempre. Ricordo che è una chat. Io l'ho fatto solo che mi scrive errore nella riga 128 e che devo mettere T_STRING, T_NUM, che cosa è?! Grazie in anticipo. Questo è il codice. (Ps, Il salvataggio del cookie è in prima riga, invece quello che lo stampa è alla riga 128)
<?
$nikko = setcookie("NIKKO","$_POST[nik]");
function tg($action, $nick, $stuffsaid, $personsite){
$talkdatafile = "tc.txt";
$sfeature = "0";
//site feature, make it 1 to enable
if ($sfeature == "1"){
if ($action == "talk") {
if(strlen($nick) >= 3){
if(strlen($stuffsaid) >= 3){
$t_fp = fopen ($talkdatafile, "a+");
$talkdate = date("H:i d/m/y");
$ip = getenv(REMOTE_ADDR);
$nicktwo = ereg_replace('<', ' ', $nick);
$nickthree = ereg_replace('>', ' ', $nicktwo);
$personsiteone = ereg_replace('<', '', $personsite);
$personsitetwo = ereg_replace('>', '', $personsiteone);
$personsitefinal = ereg_replace(' ', '', $personsitetwo);
$one_stuffsaid = ereg_replace('<', ' ', $stuffsaid);
$two_stuffsaid = ereg_replace('>', ' ', $one_stuffsaid);
$f_stuffsaid = stripslashes("$two_stuffsaid");
$f_nick = stripslashes("$nickthree");
$writedata = $talkdate."|".$f_nick."|".$f_stuffsaid."|".$person sitefinal."|".$ip."|"."\n";
$test_last = file($talkdatafile);
$test_lastr = array_reverse($test_last);
$last_e = $test_lastr[0];
if($writedata != $last_e){
fwrite ($t_fp, $writedata);
fclose ($t_fp);
}
}
}
}
} else {
if ($action == "talk") {
if(strlen($nick) >= 3){
if(strlen($stuffsaid) >= 3){
$t_fp = fopen ($talkdatafile, "a+");
$talkdate = date("H:i d/m/y");
$ip = getenv(REMOTE_ADDR);
$nicktwo = ereg_replace('<', ' ', $nick);
$nickthree = ereg_replace('>', ' ', $nicktwo);
$one_stuffsaid = ereg_replace('<', ' ', $stuffsaid);
$two_stuffsaid = ereg_replace('>', ' ', $one_stuffsaid);
$f_stuffsaid = stripslashes("$two_stuffsaid");
$f_nick = stripslashes("$nickthree");
$writedata = $talkdate."|".$f_nick."|".$f_stuffsaid."|".$ip."|" ."\n";
$test_last = file($talkdatafile);
$test_lastr = array_reverse($test_last);
$last_e = $test_lastr[0];
if($writedata != $last_e){
fwrite ($t_fp, $writedata);
fclose ($t_fp);
}
}
}
}
}
$bgcolor = "black";
$bordercolor = "red";
$height = "266";
$width = "19%";
$font = "verdana";
$fontcolor = "red";
$linkcolor = "#CC0000";
$linkhover = "red";
$inputtext = "red";
$inputbackground = "#000000";
$inputborder= "#FF0000";
echo "<html><head>\n"
."<style type=text/css><!-- input{background-color:$bgcolor;font-color:$fontcolor;font-family:$font;font-size:10px;} --></style></head>\n"
."<style type=text/css>\n"
."<!--\n"
."a:link.taglink{color:$linkcolor;font-family:$font;}\n"
."a:visited.taglink{color:$linkcolor;font-family:$font;}\n"
."a:hover.taglink{color:$linkhover;font-family:$font;}\n"
."input.tagput{color:$inputtext;font-family:$font;background-color:$inputbackground;border-color:$input-border;border-style:solid;border-width:1}\n"
."-->\n"
."</style>\n"
."<body bgcolor=$bgcolor>\n"
."<center>\n"
."<table border=0 cellpadding=0 cellspacing=0 bgcolor=$bgcolor>\n"
."<tr><td colspan=2>";echo "<table border=0 cellpadding=0 cellspacing=0 bgcolor=$bgcolor>\n"
."<tr><td>\n";echo "<table border=1 cellpadding=0 cellspacing=0 bordercolor=$bordercolor><tr><td bordercolor=$bgcolor>\n"
."<ilayer name=\"scroll1\"><div id=\"scroll3\" style=\"width:$width;height:$height;background-color:$bgcolor;overflow:auto\"><font face=$font color=$fontcolor size=1>\n";
$talks_temp = file($talkdatafile);
$talks = array_reverse($talks_temp);
$showtalks = count($talks);
if($sfeature == "1"){
for ($t = 0; $t < $showtalks; $t++) {
$talk_array = explode("|", $talks[$t]);
echo "<b><a href=".$talk_array[3]." target=new class=taglink>".$talk_array[1]."</a>:</b> ";
echo $talk_array[2]."<br>\n";
}
} else {
for ($t = 0; $t < $showtalks; $t++) {
$talk_array = explode("|", $talks[$t]);
echo "<b>".$talk_array[1].":</b> ";
echo $talk_array[2]."<br>\n";
}
}
echo "</tr></td></table>\n"
."</textarea>\n"
."</div>\n"
."</font>\n"
."</td></tr>\n"
."</table>\n"
."</table>\n"
."<table cellpadding=0 cellspacing=0><tr><td>\n"
."<form action=\"".$PHP_SELF."\" method=\"post\"><font face=$font color=$fontcolor size=1>Nome:\n"
."<td><input type=\"text\" name=\"nick\" value=\"print $_COOKIE["NIKKO"]\" class=tagput>\n"
."<tr><td><font face=$font color=$fontcolor size=1>Messaggio:<td><input type=\"text\" name=\"stuffsaid\" class=tagput><br>";
if($sfeature == "1"){
echo "<tr><td><font face=$font color=$fontcolor size=1>Site:<td><input type=\"text\" name=\"personsite\" value=\"http://\" class=tagput><br>";
} else {
echo "<!-- -->";
}
echo "</table><input type=\"submit\" name=\"tagit\" value=\"Submit\" class=tagput>\n"
."<input type=\"hidden\" name=\"action\" value=\"talk\">\n"
."</form>\n"
."</font>\n"
."</body>\n"
."</html>";
}
tg($action, $nick, $stuffsaid, $personsite);
?>
-
Non ho ben capito cosa devi fare: una chat, inserire un qualcosa. Mi spieghi un po' meglio?
Fammi sapere
-
Allora io quando apro questa pagina mi scrive:
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in /membri/babobo/tfunc.php on line 128
Io praticamente ho preso questa chat, e ogni volta che si riaggiorna, si cancellano tutti le scritte in: Nome e Messaggio. Visto che io vorrei far lasciare scritto solo il nome, ho pensato di usare i cookie. Quindi se guardi il codice in alto, alla prima riga c'è la variabile che riceve i cookie, e alla riga 128(Quella che da l'errore) c'è il cookie che dovrebbe essere stampato nel campo Nome (nick)
Capito?!
-
ehm veramente non tanto. Direi che il codice e' assolutamente incomprensibile per la mancanza di indentazione (non e' colpa tua) e per la mancanza di commenti (....) La riga 128 sarebbe quando richiami la funzione? l'ultima? bhe se dice cosi' probabilmente le variabili mancano o forse mancano delle parentesi.... Purtroppo nn ho le competenze adatte . Sorry :))))))