• User

    Errore inserimento commenti

    Ho un problema con la mia pagina dell'inserimento commenti:
    [PHP]Notice: Undefined index: ID in C:\Program Files\EasyPHP-5.3.2\www\Sito\comment.php on line 63

    Notice: Undefined variable: comment in C:\Program Files\EasyPHP-5.3.2\www\Sito\comment.php on line 72
    write a comment before submit it![/PHP]
    In questa pagina ho la mia form:
    [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="gallery.php">Gallery</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><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");
    $path=$_GET["path"];
    $title=$_GET["title"];
    $nickname=$_GET["nickname"];//nickname della persona che ha postato l'immagine
    $description=$_GET["description"];
    $ID=$_GET["ID"];//IDsketch
    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">See the comments of 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=$ID" id="comment" method="POST" name="modulo">
    <button type="submit">submit</button>
    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:/yahoo.com/" target="_blank">[email protected]</a> | </p></TD>
    </TR>
    

    </TABLE>
    </div>
    </BODY>
    </HTML>[/PHP]
    Mentre questa è la pagina dove le variabili non sono ben ricavate... Non capisco perché però!
    [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="gallery.php">Gallery</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><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
    //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";
    }
    ?>

    				</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="//yahoo.com/" target="_blank">[email protected]</a> | </p></TD>
    </TR>
    

    </TABLE>
    </div>
    </BODY>
    </HTML>[/PHP]
    Tralasciando poi che devo sempre finirla anche graficamente, cos'ho sbagliato? Sapete darmi una mano? 😞
    Grazie della pazienza!


  • ModSenior

    Ciao sappe,
    $comment viene utilizzata senza essere stata da nessuna parte definita.