Questo è (forse, se non ne sorgono altri xD) l'ultimo problema che devo risolvere!
Questo è il codice dell'immagine, che sotto si può commentare. Posso andare sia alla lista dei commenti riferiti a quell'immagine sia commentare io stesso (utente) l'immagine che sto visualizzando.... Questa è la pagina dell'immagine:
e questa la pagina dei commenti:
questo il codice degli errori:
Sto facendo una confusione assurda!! ((
Sapete aiutarmi? Grazie in anticipo!! Anche per la pazienza!!
Questo è il codice dell'immagine, che sotto si può commentare. Posso andare sia alla lista dei commenti riferiti a quell'immagine sia commentare io stesso (utente) l'immagine che sto visualizzando.... Questa è la pagina dell'immagine:
PHP:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<?php session_start();
?>
<HTML>
<HEAD>
<TITLE>Image</TITLE><link href="style.css" rel="stylesheet" type="text/css">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
</HEAD>
<BODY>
<div align="center">
<TABLE class="maintable" CELLPADDING="0" CELLSPACING="0">
<TR>
<TD COLSPAN=3> <IMG SRC="images/index_01.gif" WIDTH=727 HEIGHT=240 ALT=""></TD>
</TR>
<TR>
<TD ROWSPAN=2 class="navbg" valign="top"><div id="nav">
<p><span class="h2">Menu</span> <a href="index.php">Home</a> <a href="rules.php">Rules</a>
<a href="faq.php">F.A.Q.</a> <a href="upload.php">Upload</a> <a href="search.php">Search</a>
<span class="endbox"></span> </p>
<?php
if ((isset($_SESSION['login']))&&((isset($_SESSION['password'])))){
echo <<<print
<p><span class="h2">Logout</span> <a href="profile.php">Your Profile</a> <a href="logout.php">Logout</a><span class="endbox"></span> </p>
<p><span class="h2">Friendship</span> <a href="users.php">Search user</a> <a href="friend.php">My friends</a> <a href="request.php">Friends request</a> <span class="endbox"></span> </p>
print;
}
else {
echo <<<print
<p><span class="h2">Sign in</span> <a href="create.html">Create account</a> <a href="login.htm">Login</a><span class="endbox"></span></p>
print;
}
?>
<?php
include("connessione.inc");
if (isset($_SESSION['login'])) {
$login = $_SESSION['login'];
$sqlA="SELECT Nickname FROM utenti WHERE Nickname = '$login' AND Admin = '1'";
$resA=mysql_query($sqlA,$conn)or die("Error!".mysql_error());
$lines=mysql_num_rows($resA);
if ($lines == 1){
echo <<<print
<p><span class="h2">Admin</span> <a href="admin.php">Administration</a> <a href="banned.php">Users banned</a><span class="endbox"></span></p>
print;
}
}
echo <<<print
</p>
</div></TD>
<TD ROWSPAN=2 class="contentbg" valign="top"><div id="content">
print;
?>
<h1>Image</h1>
<p>
<?php
include("connessione.inc");
//controllo se l'utente è loggato
if ((isset($_SESSION['login']))&&((isset($_SESSION['password'])))){
$login=$_SESSION['login'];
$sql="SELECT Nickname FROM utenti WHERE Nickname = '$login' AND Admin = '1'";
$res=mysql_query($sql,$conn)or die("Error!".mysql_error());
$lines=mysql_num_rows($res);
$nickname=$_GET["nickname"];//nickname della persona che ha postato l'immagine
//non torna nel visualizza immagini la query che fa visualizzare l'immagine all'utente che l'ha hostata
$sql2="SELECT * FROM utenti JOIN immagini ON utenti.IDutente = immagini.Author AND Nickname = '$nickname'";
$res2=mysql_query($sql2,$conn)or die("Error!".mysql_error());
$lines2=mysql_num_rows($res2);
if ($lines2 == 1){
echo "<align='center'>You are the author of this image.</align>";
}
//non funziona neanche se sono amici
$sql3="SELECT * FROM utenti JOIN amicizie ON (amicizie.Receiver = utenti.IDutente) or (amicizie.Sender = utenti.IDutente) AND Friend = '1'";
$res3=mysql_query($sql3,$conn)or die("Error!".mysql_error());
$lines3=mysql_num_rows($res3);
$path=$_GET["path"];
$title=$_GET["title"];
$description=$_GET["description"];
$ID=$_GET["ID"];//IDsketch
if ($lines == 1){
echo <<<MESS
<a href="deleteImage.php?ID=$ID" onclick="return confirm('Do you really want to delete this image?')">Delete Image</a>
MESS;
}
if ($lines == 1 or $lines2 == 1 or $lines3 == 1){
echo <<<MESS
<table summary="immagine" border="1" id="image" align="center">
<tr align="center"><td><a href="$_GET[path]"><img src=$_GET[path] style="width: 60%;"></a></td></tr><tr><th>$title</th><tr><td>by $nickname</td></tr><tr><td>$description</td></tr></table>
<a href="comment.php?ID=$ID&nickname=$nickname">See the comments about this image</a></br>
<p><b>Comment</b></br>Write a comment:</br>
<textarea name="comment" cols="40" rows="4" maxlength="300">
</textarea>
<FORM enctype="multipart/form-data" action="comment.php" id="comment" method="POST" name="modulo">
<index type="hidden" name="$ID" value="ID">
<index type="hidden" name="$nickname" value="nickname">
<button type="submit" onclick="return confirm('Do you really want to comment this image?')">Add</button>
MESS;
}
else{
echo "You can't see this image (you and $nickname aren't friend).";
}
} //chiude l'if del controllo login
else {
echo "You are not logged in and you can't see this image!";
}
?>
</p>
</br>
</br>
</br>
</br>
<h1>©SketchMania</h1>
<TD valign="top" class="spacer"></TD>
</TR><TR>
<TD height="2" class="spacer2"></TD>
</TR><TR>
<TD COLSPAN=3 class="creditsbg">
<p>| Contact us <a href="http://yahoo.com/" target="_blank">[email protected]</a> | </p></TD>
</TR>
</TABLE>
</div>
</BODY>
</HTML>
PHP:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<?php session_start();
?>
<HTML>
<HEAD>
<TITLE>Comments</TITLE><link href="style.css" rel="stylesheet" type="text/css">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
</HEAD>
<BODY>
<div align="center">
<TABLE class="maintable" CELLPADDING="0" CELLSPACING="0">
<TR>
<TD COLSPAN=3> <IMG SRC="images/index_01.gif" WIDTH=727 HEIGHT=240 ALT=""></TD>
</TR>
<TR>
<TD ROWSPAN=2 class="navbg" valign="top"><div id="nav">
<p><span class="h2">Menu</span> <a href="index.php">Home</a> <a href="rules.php">Rules</a>
<a href="faq.php">F.A.Q.</a> <a href="upload.php">Upload</a> <a href="search.php">Search</a>
<span class="endbox"></span> </p>
<?php
if ((isset($_SESSION['login']))&&((isset($_SESSION['password'])))){
echo <<<print
<p><span class="h2">Logout</span> <a href="profile.php">Your Profile</a> <a href="logout.php">Logout</a><span class="endbox"></span> </p>
<p><span class="h2">Friendship</span> <a href="users.php">Search user</a> <a href="friend.php">My friends</a> <a href="request.php">Friends request</a> <span class="endbox"></span> </p>
print;
}
else {
echo <<<print
<p><span class="h2">Sign in</span> <a href="create.html">Create account</a> <a href="login.htm">Login</a><span class="endbox"></span></p>
print;
}
?>
<?php
include("connessione.inc");
if (isset($_SESSION['login'])) {
$login = $_SESSION['login'];
$sqlA="SELECT Nickname FROM utenti WHERE Nickname = '$login' AND Admin = '1'";
$resA=mysql_query($sqlA,$conn)or die("Error!".mysql_error());
$lines=mysql_num_rows($resA);
if ($lines == 1){
echo <<<print
<p><span class="h2">Admin</span> <a href="admin.php">Administration</a> <a href="banned.php">Users banned</a><span class="endbox"></span></p>
print;
}
}
echo <<<print
</p>
</div></TD>
<TD ROWSPAN=2 class="contentbg" valign="top"><div id="content">
print;
?>
<h1>Comments</h1>
<p>
<?php
include("connessione.inc");
$ID=$_GET["ID"];//IDsketch
$nickname=$_GET["nickname"];//nickname utente
//la mia idea era: prima di tutto seleziono l'utente che ha per nickname $nickname, dalla quale ricavo l'id, poi con l'id ricavo il commento
$sqlB="SELECT * FROM utenti WHERE Nickname = '$nickname'";
$resB=mysql_query($sqlB,$conn)or die("Error!".mysql_error());
while ($records=mysql_fetch_assoc($resB)){
$IDuser=$records['IDutente'];
}
$sqlC="SELECT * FROM commenti WHERE User = '$IDuser'";
$resC=mysql_query($sqlC,$conn)or die("Error!".mysql_error());
while ($records=mysql_fetch_assoc($resC)){
$comment=$records['Commento'];
}
//per prima cosa fare l'inserisci commenti: nickcomment ID del commentatore
function control ($comment){
$result=true;
if ($comment ==''){
$result=false;
echo "Write a comment before submit it!";
}
}
if (control($comment) == true){
$sql="INSERT INTO commenti(IDcommento, User, Sketch, Commento) VALUES ($IDcommento, $nickcomment, $ID, $comment)";
$res=mysql_query($sql,$conn)or die("Error!".mysql_error());
echo "Your comment it's been added.</br>$IDcommento, $nickcomment, $ID, $comment</hr>";
}
//stampo tutti i commenti degli utenti (ma devono essere relativi a quest'immagine!):
$sqlF="SELECT * FROM commenti WHERE Sketch='$ID'";
$resF=mysql_query($sqlF,$conn)or die("Error!".mysql_error());
$linesF = mysql_num_rows($resF);
if (lines == 1){
echo <<<MESS
</br>
$nickcomment: </br>
$comment</hr>
MESS;
}
else { echo "No one have comment this image."; }
//se sei admin vedi un cancella commenti
if (isset($_SESSION['login'])) {
$login = $_SESSION['login'];
$sqlA="SELECT Nickname FROM utenti WHERE Nickname = '$login' AND Admin = '1'";
$resA=mysql_query($sqlA,$conn)or die("Error!".mysql_error());
$lines=mysql_num_rows($resA);
if ($lines == 1){
echo <<<MESS
</br><a href="deleteComment.php?IDcommento=$ID" onclick="return confirm('Do you really want to delete this comment?')">Delete Comment</a></br>
MESS;
}
}
?>
</p>
</br>
</br>
</br>
</br>
<h1>©SketchMania</h1>
<TD valign="top" class="spacer"></TD>
</TR><TR>
<TD height="2" class="spacer2"></TD>
</TR><TR>
<TD COLSPAN=3 class="creditsbg">
<p>| Contact us <a href="http://yahoo.com/" target="_blank">[email protected]</a> | </p></TD>
</TR>
</TABLE>
</div>
</BODY>
</HTML>
questo il codice degli errori:
PHP:
Notice: Undefined index: ID in C:\Program Files\EasyPHP-5.3.2\www\Sito\comment.php on line 63
Notice: Undefined index: nickname in C:\Program Files\EasyPHP-5.3.2\www\Sito\comment.php on line 64
Notice: Undefined variable: IDuser in C:\Program Files\EasyPHP-5.3.2\www\Sito\comment.php on line 72
Notice: Undefined variable: comment in C:\Program Files\EasyPHP-5.3.2\www\Sito\comment.php on line 86
Write a comment before submit it!
Notice: Use of undefined constant lines - assumed 'lines' in C:\Program Files\EasyPHP-5.3.2\www\Sito\comment.php on line 95
No one have comment this image.
Delete Comment
Sapete aiutarmi? Grazie in anticipo!! Anche per la pazienza!!