Condividi:        

[PHP] e problemi di include o require

Problemi di HTML? Di PHP, ASP, .NET, JSP, Perl, SQL, JavaScript, Visual Basic..?
Vuoi realizzare programmi in C, C++, Java, Ruby o Smalltalk, e non sai da che parte cominciare?
Entra qui e troverai le risposte!

Moderatori: Anthony47, Triumph Of Steel, archimede

[PHP] e problemi di include o require

Postdi Dylan666 » 04/11/06 17:50

Ho creato un piccolo sito il cui menù di navigazione richiama via "include" i vari conenuti della pagina salvati in file php separati.
Insomma, l'header è sempre lo stesso ma se clicchi su "presentezione" sotto appare presentezione.php, se clicchi su "foto" appaiono le foto di foto.php ecc.

Ora dovrei includere questo script (pare lungo ma è molto sempice):


Codice: Seleziona tutto
<?


   include ("calendario/connessione.php");
?>


<script>

function popup2(username)
{
   window.open('modificautente.php?username='+username,'','scrollbars=yes,resizable=no,width=300,height=300');
}
</script>

<center><table border="0" cellspacing="1" cellpadding="1" width="100%" height="10%">
<tr>
<td align="center" valign="middle">

<?
//########################################################
//#########          Auto log-in            #########
//########################################################   
   
   $username="saibal";
   $password="saibal";
   
//########################################################
//######### Ingresso servizio con riconoscimento #########
//########################################################

if ($contatore=="")
{
   $stringa21="SELECT * FROM logineventi WHERE username='$username' and password='$password'";
   $rs_query21=mysql_query(($stringa21),$link);
   
   if (mysql_num_rows($rs_query21)>0)
   {
      ?>
      <form method="post" action="calendario.php" name="certifica">
      <input type="hidden" name="contatore" value="1">
      <input type="hidden" name="username" value="<?echo $username?>">
      <input type="hidden" name="mon" value="<?echo date("m")?>">
      <input type="hidden" name="year" value="<?echo date("Y")?>">
      <input type="hidden" name="sam" value="1">
      </form>
      <script>document.certifica.submit();</script>
      <?
   }
   else
   {
      ?>

      <?
   }
}
//########################################################
//######### Visualizzazione mese-anno in corso ###########
//######### con possibilità di variare entrambi ##########
//########################################################
elseif($contatore=="1")
{
      $stringa21="SELECT * FROM logineventi WHERE username='$username'";
      $rs_query21=mysql_query(($stringa21),$link);
      $rs21=mysql_fetch_array($rs_query21);
      $idlog=$rs21["idloginevento"];







      if (!$HTTP_POST_VARS)
      {
         $theDate = getdate();
         $mon = $theDate["mon"];
         $month = $theDate["month"];
         $year = $theDate["year"];   
      }
      
      if ($action = "findDate")
      {
         $mese=$mon;
         if ($mese=="01"){$mese="Gennaio";}
         elseif ($mese=="02"){$mese="Febbraio";}
         elseif ($mese=="03"){$mese="Marzo";}
         elseif ($mese=="04"){$mese="Aprile";}
         elseif ($mese=="05"){$mese="Maggio";}
         elseif ($mese=="06"){$mese="Giugno";}
         elseif ($mese=="07"){$mese="Luglio";}
         elseif ($mese=="08"){$mese="Agosto";}
         elseif ($mese=="09"){$mese="Settembre";}
         elseif ($mese=="10"){$mese="Ottobre";}
         elseif ($mese=="11"){$mese="Novembre";}
         elseif ($mese=="12"){$mese="Dicembre";}
         $month=$mese;
      }

      $tempDate = getdate(mktime(0,0,0,$mon,1,$year));
      $firstwday= $tempDate["wday"];
      $cont = true;
      $tday = 27;

      while (($tday <= 32) && ($cont))
      {
         $tdate = getdate(mktime(0,0,0,$mon,$tday,$year));
         if ($tdate["mon"] != $mon)
         {
            $lastday = $tday - 1;
            $cont = false;
         }
         $tday++;
      }

      ?>
<br>
Da qui c'è la tabella
<br>
            
<table width="20%" border="1" cellspacing="0" cellpadding="6" bordercolor="#000000">   

      <form method="post" action="calendario.php">
      <TR>
      <TD colspan="7" align="center">
         <input type="hidden" name="action" value="findDate">
         <input type="hidden" name="contatore" value="1">
         <input type="hidden" name="username" value="<?echo $username?>">
         Vai a:
         <?
         if ($mon==$mon)
         {
            $sel=" SELECTED";
         }
         ?>
         <select name="mon">
         <?
         $s=0;
         while ($s<12)
         {
            $a=date("m",mktime(0,0,0,date("m")+$s,date("d"),date("Y")));

            if (strlen($a)=="1")
            {
               $a="0".$a;
            }

            if ($a==$mon)
            {
               ?>
               <option value="<?echo date("m",mktime(0,0,0,date("m")+$s,date("d"),date("Y")));?>" selected>
                  <?
                  $me1=date("m",mktime(0,0,0,date("m")+$s,date("d"),date("Y")));
                  if ($me1=="01"){$me1="Gennaio";}
                  elseif ($me1=="02"){$me1="Febbraio";}
                  elseif ($me1=="03"){$me1="Marzo";}
                  elseif ($me1=="04"){$me1="Aprile";}
                  elseif ($me1=="05"){$me1="Maggio";}
                  elseif ($me1=="06"){$me1="Giugno";}
                  elseif ($me1=="07"){$me1="Luglio";}
                  elseif ($me1=="08"){$me1="Agosto";}
                  elseif ($me1=="09"){$me1="Settembre";}
                  elseif ($me1=="10"){$me1="Ottobre";}
                  elseif ($me1=="11"){$me1="Novembre";}
                  elseif ($me1=="12"){$me1="Dicembre";}
                  echo $me1;
                  ?>
               </option>
               <?
            }
            else
            {
               ?>
               <option value="<?echo date("m",mktime(0,0,0,date("m")+$s,date("d"),date("Y")));?>">
                  <?
                  $me2=date("m",mktime(0,0,0,date("m")+$s,date("d"),date("Y")));
                  if ($me2=="01"){$me2="Gennaio";}
                  elseif ($me2=="02"){$me2="Febbraio";}
                  elseif ($me2=="03"){$me2="Marzo";}
                  elseif ($me2=="04"){$me2="Aprile";}
                  elseif ($me2=="05"){$me2="Maggio";}
                  elseif ($me2=="06"){$me2="Giugno";}
                  elseif ($me2=="07"){$me2="Luglio";}
                  elseif ($me2=="08"){$me2="Agosto";}
                  elseif ($me2=="09"){$me2="Settembre";}
                  elseif ($me2=="10"){$me2="Ottobre";}
                  elseif ($me2=="11"){$me2="Novembre";}
                  elseif ($me2=="12"){$me2="Dicembre";}
                  echo $me2;
                  ?>
               </option>
               <?
            }
            $s=$s+1;
         }
         ?>
         </select>
         <select name="year">
         <?
         $s=0;
         while ($s<12)
         {
            $a=date("Y",mktime(0,0,0,date("m"),date("d"),date("Y")+$s));

            if ($a==$year)
            {
               ?>
               <option value="<?echo date("Y",mktime(0,0,0,date("m"),date("d"),date("Y")+$s));?>" selected><?echo date("Y",mktime(0,0,0,date("m"),date("d"),date("Y")+$s));?></option>
               <?
            }
            else
            {
               ?>
               <option value="<?echo date("Y",mktime(0,0,0,date("m"),date("d"),date("Y")+$s));?>"><?echo date("Y",mktime(0,0,0,date("m"),date("d"),date("Y")+$s));?></option>
               <?
            }
            $s=$s+1;
         }
         ?>
         </select>
         <input type="submit" value="Vai">
      </td>
      </tr>
      </form>

      <tr>
      <td colspan="7">
         <table width="100%" border="0">
         <tr>
         <td align="center" valign="center">
            <form method="post" action="calendario.php">
            <input type="hidden" name="action" value="findDate">
            <input type="hidden" name="contatore" value="1">
            <input type="hidden" name="username" value="<?echo $username?>">
            <input type="hidden" name="mon" value="<?if (($mon-1)<1) { echo "12"; }else { echo $mon-1; } ?>">
            <input type="hidden" name="year" value="<?if (($mon-1)<1) { echo $year-1; }else { echo $year; } ?>">
            <br><input type="submit" value="<< Indietro">
            </FORM>
         </td>
         <td align="center">
            <?echo " <b>$month $year</b> ";?>
         </TD>
         <td align="center" valign="center">
            <form method="post" action="<? echo $PHP_SELF; ?>">
            <input type="hidden" name="action" value="findDate">
            <input type="hidden" name="contatore" value="1">
            <input type="hidden" name="username" value="<?echo $username?>">
            <input type="hidden" name="mon" value="<?if (($mon+1)>12) { echo "1"; } else { echo $mon+1; } ?>">
            <input type="hidden" name="year" value="<?if (($mon+1)>12) { echo $year+1; }else { echo $year; } ?>">
            <br><input type="submit" value="Avanti >>">
            </FORM>
         </td>
         </tr>
         </table>
      </td>
      </tr>
      <tr>
      <th width="13%">Domenica</th>
      <th width="13%">Lunedì</th>
      <th width="13%">Martedì</th>
      <th width="13%">Mercoledì</th>
      <th width="13%">Giovedì</th>
      <th width="13%">Venerdì</th>
      <th width="13%">Sabato</th>
      </tr>
      <?  $d = 1;
          $thisDay = date('d');
          $thisMon = date('n');
          $thisMonth = date('F');
          $thisYear = date('Y');
          $wday = $firstwday;
          $firstweek = true;

          while ( $d <= $lastday)
          {

         if (strlen($d)=="1")
         {
            $d="0".$d;
         }
         if (strlen($mon)=="1")
         {
            $mon="0".$mon;
         }
         $dataformattata=$year."-".$mon."-".$d;

         if ($firstweek)
         {
             echo "<tr>";
             for ($i=1; $i<=$firstwday; $i++)
             {
            echo "<td height='100'>&nbsp;</td>";
             }
             $firstweek = false;
         }

         if ($wday==0)
         {
             echo "<tr>";
         }
         echo "<td height='100'";

         if (($d == $thisDay) && ($mon == $thisMon) && ($year == $thisYear))
         {
            echo " bgcolor=\"yellow\"";
         }
         echo "><font color=black> $d ";

         $stringa16="SELECT * FROM eventi WHERE idloginevento='$idlog'";
         $rs_query16=mysql_query(($stringa16),$link);

         $r="1";
         while($rs16=mysql_fetch_array($rs_query16))
         {
            $confrontodata=$rs16["data"];
            $evento=$rs16["evento"];

            if ($confrontodata==$dataformattata)
            {
               ?>
               <form name="espandi<?echo $r?>" method="post" action="calendario.php">
               <input type="hidden" name="contatore" value="3">
               <input type="hidden" name="username" value="<?echo $username?>">
               <input type="hidden" name="mon" value="<?echo $mon?>">
               <input type="hidden" name="year" value="<?echo $year?>">
               <input type="hidden" name="idevento" value="<?echo $rs16["idevento"]?>">
               <a href="javascript:document.espandi<?echo $r?>.submit();">
               <p><img src="calendario/images/frecciarossa.gif" border="0"><?echo $evento?></p>
               </a>
               </form>
               <?
            }
            $r=$r+1;
         }

         echo "</font></td>";

         if ($wday==6)
         {
             echo "</tr>";
         }

         


         $wday++;
         $wday = $wday % 7;
         $d++;
         
          }
         
          ?>

      </table>

      <form method="post" action="calendario.php" name="certifica">
      <input type="hidden" name="contatore" value="1">
      <input type="hidden" name="username" value="<?echo $username?>">
      <input type="hidden" name="mon" value="<?echo date("m")?>">
      <input type="hidden" name="year" value="<?echo date("Y")?>">
      <input type="hidden" name="sam" value="1">
      </form>
      <?
}
//########################################################
//######### Inserimento nuovo Evento #####################
//########################################################
elseif($contatore=="2")
{
   ?>
   <form name="insevento" method="post" action="calendario.php">
   <table align="center" width="40%" border="1" bordercolor="#000000">
   <tr>
      <th align="center" colspan="2">Inserisci un Appuntamento</th>
   </tr>
   <tr>
      <th align="left">Evento</th>
      <td align="center"><input type="text" name="evento" size="35"></td>
   </tr>
   <tr>
      <th align="left">DescrizioneEvento</th>
      <td align="center"><textarea cols="35" rows="10" name="descrizioneevento"></textarea></td>
   </tr>
   <tr>
      <th align="left">Data</th>
      <td align="center">
         <select name="data">
            <?
            $s=0;
            while ($s<365)
            {
               $a=date("Y-m-d",mktime(0,0,0,date("m"),date("d")+$s,date("Y")));
            
               if ($a==$data)
               {
                  ?>
                  <option value="<?echo date("Y-m-d",mktime(0,0,0,date("m"),date("d")+$s,date("Y")));?>" selected>
                     <?
                     $gi1=date("d",mktime(0,0,0,date("m"),date("d")+$s,date("Y")));
                     $me1=date("m",mktime(0,0,0,date("m"),date("d")+$s,date("Y")));
                     if ($me1=="01"){$me1="Gennaio";}
                     elseif ($me1=="02"){$me1="Febbraio";}
                     elseif ($me1=="03"){$me1="Marzo";}
                     elseif ($me1=="04"){$me1="Aprile";}
                     elseif ($me1=="05"){$me1="Maggio";}
                     elseif ($me1=="06"){$me1="Giugno";}
                     elseif ($me1=="07"){$me1="Luglio";}
                     elseif ($me1=="08"){$me1="Agosto";}
                     elseif ($me1=="09"){$me1="Settembre";}
                     elseif ($me1=="10"){$me1="Ottobre";}
                     elseif ($me1=="11"){$me1="Novembre";}
                     elseif ($me1=="12"){$me1="Dicembre";}
                     $an1=date("Y",mktime(0,0,0,date("m"),date("d")+$s,date("Y")));
                     echo $gi1." - ".$me1." - ".$an1;
                     ?>
                  </option>
                  <?
               }
               else
               {
                  ?>
                  <option value="<?echo date("Y-m-d",mktime(0,0,0,date("m"),date("d")+$s,date("Y")));?>">
                     <?
                     $gi2=date("d",mktime(0,0,0,date("m"),date("d")+$s,date("Y")));
                     $me2=date("m",mktime(0,0,0,date("m"),date("d")+$s,date("Y")));
                     if ($me2=="01"){$me2="Gennaio";}
                     elseif ($me2=="02"){$me2="Febbraio";}
                     elseif ($me2=="03"){$me2="Marzo";}
                     elseif ($me2=="04"){$me2="Aprile";}
                     elseif ($me2=="05"){$me2="Maggio";}
                     elseif ($me2=="06"){$me2="Giugno";}
                     elseif ($me2=="07"){$me2="Luglio";}
                     elseif ($me2=="08"){$me2="Agosto";}
                     elseif ($me2=="09"){$me2="Settembre";}
                     elseif ($me2=="10"){$me2="Ottobre";}
                     elseif ($me2=="11"){$me2="Novembre";}
                     elseif ($me2=="12"){$me2="Dicembre";}
                     $an2=date("Y",mktime(0,0,0,date("m"),date("d")+$s,date("Y")));
                     echo $gi2." - ".$me2." - ".$an2;
                     ?>
                  </option>
                  <?
               }
               $s=$s+1;
            }
            ?>
         </select>
      </td>
   </tr>
   <tr>
      <td align="center" colspan="2">
         <input type="submit" name="vai" value="Vai">
         <input type="button" name="torna" value="Torna" onClick="history.back()">
      </td>
   </tr>
   </table>
   <input type="hidden" name="contatore" value="1">
   <input type="hidden" name="inserito" value="1">
   <input type="hidden" name="mon" value="<?echo date("m")?>">
   <input type="hidden" name="year" value="<?echo date("Y")?>">
   <input type="hidden" name="username" value="<?echo $username?>">
   </form>
   <?   
}
//########################################################
//######### Modifica/Cancella Evento #####################
//########################################################
elseif($contatore=="3")
{
   $stringa16="SELECT * FROM eventi WHERE idevento='$idevento'";
   $rs_query16=mysql_query(($stringa16),$link);
   $rs16=mysql_fetch_array($rs_query16);

   ?>
   <form name="modevento" method="post" action="calendario.php">
   <table align="center" width="40%" border="1" bordercolor="#000000">
   <tr>
      <th align="center" colspan="2">Dettagli dell' Appuntamento</th>
   </tr>
   <tr>
      <th align="left">Evento</th>
      <td align="center"><input type="text" readonly name="evento" size="35" value="<?echo $rs16['evento']?>"></td>
   </tr>
   <tr>
      <th align="left">DescrizioneEvento</th>
      <td align="center"><textarea readonly cols="35" rows="10" name="descrizioneevento"><?echo $rs16["descrizioneevento"]?></textarea></td>
   </tr>
   <tr>
      <th align="left">Data</th>
      <td align="center">

            <?
            $s=0;
            while ($s<365)
            {
               $a=date("Y-m-d",mktime(0,0,0,date("m"),date("d")+$s,date("Y")));
               $b=$rs16["data"];
            
               if ($a==$b)
               {
                     $gi1=date("d",mktime(0,0,0,date("m"),date("d")+$s,date("Y")));
                     $me1=date("m",mktime(0,0,0,date("m"),date("d")+$s,date("Y")));
                     if ($me1=="01"){$me1="Gennaio";}
                     elseif ($me1=="02"){$me1="Febbraio";}
                     elseif ($me1=="03"){$me1="Marzo";}
                     elseif ($me1=="04"){$me1="Aprile";}
                     elseif ($me1=="05"){$me1="Maggio";}
                     elseif ($me1=="06"){$me1="Giugno";}
                     elseif ($me1=="07"){$me1="Luglio";}
                     elseif ($me1=="08"){$me1="Agosto";}
                     elseif ($me1=="09"){$me1="Settembre";}
                     elseif ($me1=="10"){$me1="Ottobre";}
                     elseif ($me1=="11"){$me1="Novembre";}
                     elseif ($me1=="12"){$me1="Dicembre";}
                     $an1=date("Y",mktime(0,0,0,date("m"),date("d")+$s,date("Y")));
                     echo $gi1." - ".$me1." - ".$an1;

               }
               $s=$s+1;
            }
   }
            ?>

      </td>
   </tr>
   <tr>
      <td align="center" colspan="2">
         <input type="button" name="torna" value="Torna" onClick="history.back()">
      </td>
   </tr>
   </table>   

</td>
</tr>
</table></center>



Ma quando lo vado a richiamare appare da solo, cioè fa scomparire la pagina "contenitrice" con l'header. Come risolvo?
Avatar utente
Dylan666
Moderatore
 
Post: 39994
Iscritto il: 18/11/03 16:46

Sponsor
 

Postdi Dylan666 » 04/11/06 18:32

Restringiamo il campo: il problema è qui

Codice: Seleziona tutto
   if (mysql_num_rows($rs_query21)>0)
   {
      ?>
      <form method="post" action="calendario.php" name="certifica">
      <input type="hidden" name="contatore" value="1">
      <input type="hidden" name="username" value="<?echo $username?>">
      <input type="hidden" name="mon" value="<?echo date("m")?>">
      <input type="hidden" name="year" value="<?echo date("Y")?>">
      <input type="hidden" name="sam" value="1">
      </form>
      <script>document.certifica.submit();</script>
      <?
   }


Come faccio a passargli questi valori senza fare il submit automatico che causa il problema?
Avatar utente
Dylan666
Moderatore
 
Post: 39994
Iscritto il: 18/11/03 16:46


Torna a Programmazione


Topic correlati a "[PHP] e problemi di include o require":


Chi c’è in linea

Visitano il forum: Nessuno e 15 ospiti