parrymason Posted March 28, 2005 Report Share Posted March 28, 2005 (edited) Man ir šāds skripts lapā: <?php switch ($_REQUEST['lapa']) { case 'lapa1': include_once('lapas/lapa1.php'); break; case 'lapa2': include_once('lapas/lapa2.php'); break; case 'lapa3': include_once('lapas/lapa3.php'); break; default: include_once('lapas/saturs.php'); break; } ?> Viss strādā, lapas mainās kā vajag, tikai ieejot index.php parādās tas saturs.php, bet vēl parādās arī šis: Notice: Undefined index: sadala in e:\program files\easyphp1-7\www\index.php on line 21 Kas tur pietrūkst? Edited March 28, 2005 by parrymason Link to comment Share on other sites More sharing options...
rudzis Posted March 28, 2005 Report Share Posted March 28, 2005 Rādi visu kodu! Link to comment Share on other sites More sharing options...
hu_ha Posted March 28, 2005 Report Share Posted March 28, 2005 nu tev tak saka, ka nav definēts mainīgais "sadala". vai nu pirms mainīgā lietošanas nodefinē viņu, kaut vai $sadala=''; vai $sadala=0; vai arī veic pārbaudi if (isset($sadala)) Link to comment Share on other sites More sharing options...
bubu Posted March 28, 2005 Report Share Posted March 28, 2005 Šī kļūda nozīmē, ka tu masīvam izmanto indeksu 'sadala', kad reāli tāds masīva elements nemaz neeksistē. Link to comment Share on other sites More sharing options...
parrymason Posted March 28, 2005 Author Report Share Posted March 28, 2005 <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1257"> <title>Tests</title> </head> <body> <div align="center"> <table border="1" width="800" height="800" cellspacing="0" cellpadding="0"> <tr> <td height="60" colspan="3"> </td> </tr> <tr> <td width="145" height="319" valign="top" background="wallbackground2.gif"><p><a href="http://localhost/tabula.php?sadala=lapa1">links 1</a></p> <p><a href="http://localhost/tabula.php?sadala=lapa2">links2</a></p> <p><a href="http://localhost/tabula.php?sadala=lapa3">links3</a> </p></td> <td width="504" height="319" valign="top"> <?php switch ($_REQUEST['sadala']) { case 'lapa1': include_once('sadalas/lapa1.php'); break; case 'lapa2': include_once('sadalas/lapa2.php'); break; case 'lapa3': include_once('sadalas/lapa3.php'); break; default: include_once('sadalas/saturs.php'); break; } ?> </td> <td width="143" height="319" valign="top" background="wallbackground2.gif"> </td> </tr> <tr> <td height="20" colspan="3"> </td> </tr> </table> </div> </body> </html> Link to comment Share on other sites More sharing options...
hu_ha Posted March 28, 2005 Report Share Posted March 28, 2005 pārveido <?php switch ($_REQUEST['sadala']) uz <?php if (isset($_REQUEST['sadala'])) $sadala=parbaude($_REQUEST['sadala']); else $sadala=''; switch ($sadala) un switch vari pielikt default, kur apstrādāt visus izņēmuma gadījumus Link to comment Share on other sites More sharing options...
parrymason Posted March 28, 2005 Author Report Share Posted March 28, 2005 Labi, bija kļūda, šur tur "lapa" vietā biju lietojis vārdu "sadaļa", tagad viss ir "sadaļa", bet tāpat neiet kā vajag. Link to comment Share on other sites More sharing options...
parrymason Posted March 28, 2005 Author Report Share Posted March 28, 2005 (edited) pārveido <?php switch ($_REQUEST['sadala']) uz <?php if (isset($_REQUEST['sadala'])) $sadala=parbaude($_REQUEST['sadala']); else $sadala=''; switch ($sadala) un switch vari pielikt default, kur apstrādāt visus izņēmuma gadījumus 15689[/snapback] Paldies! Vairāk problēmu nav, izņemot šo: Fatal error: Call to undefined function: parbaude() in e:\program files\easyphp1-7\www\tabula.php on line 24 Kādai jābūt tai pārbaudei? Edited March 28, 2005 by parrymason Link to comment Share on other sites More sharing options...
bubu Posted March 28, 2005 Report Share Posted March 28, 2005 Kā lai mēs to zinām? Link to comment Share on other sites More sharing options...
Kristabs Posted March 28, 2005 Report Share Posted March 28, 2005 <?php if (isset($_REQUEST['sadala'])) { $sadala=($_REQUEST['sadala']); } else { $sadala=''; } switch ($sadala){ case... } ?> Link to comment Share on other sites More sharing options...
parrymason Posted March 28, 2005 Author Report Share Posted March 28, 2005 <?php if (isset($_REQUEST['sadala'])) { $sadala=($_REQUEST['sadala']); } else { $sadala=''; } switch ($sadala){ case... } ?> 15693[/snapback] Paldies, viss strādā! Link to comment Share on other sites More sharing options...
hu_ha Posted March 28, 2005 Report Share Posted March 28, 2005 Paldies, viss strādā! 15694[/snapback] Strādāt ta varbūt strādā, bet funkciju parbaude() nebiju ielicis velti. Bija domāts, ka tu aizdomāsies par lapas drošību, jo nepārbaudot mainīgo, kas tiek saņemts no linka, tu pieļauj lielu kļūdu drošības virzienā. Link to comment Share on other sites More sharing options...
parrymason Posted March 28, 2005 Author Report Share Posted March 28, 2005 Tomēr vēl viena lieta: linki ir šādi : <a href="http://localhost/tabula.php?lapa=lapa2">links2</a> Bet ja nu es nomainu hostingu, tad jāpārraksta visi linki pilnīgi visur? Link to comment Share on other sites More sharing options...
parrymason Posted March 28, 2005 Author Report Share Posted March 28, 2005 Strādāt ta varbūt strādā, bet funkciju parbaude() nebiju ielicis velti. Bija domāts, ka tu aizdomāsies par lapas drošību, jo nepārbaudot mainīgo, kas tiek saņemts no linka, tu pieļauj lielu kļūdu drošības virzienā. 15695[/snapback] Neesmu vēl tādu līmeni sasniedzis, lai pārzinātu drošības jautājumus. Manas pašreizējās lapas noteikti ir caurumainas un nedrošas, es pat nezinu, kā to pārbauda. Link to comment Share on other sites More sharing options...
hu_ha Posted March 28, 2005 Report Share Posted March 28, 2005 liec realatīvos linkus <a href="tabula.php?lapa=lapa2">links2</a> <a href="../tabula.php?lapa=lapa2">links2</a> utt. Neesmu vēl tādu līmeni sasniedzis, lai pārzinātu drošības jautājumus Ja jau reiz mācies, tad par to ar der painteresēties un padomāt. Šajā gadījumā tiesa gan neko izdarīt nevar, bet, ja mainīgo $sadala izmantosi vēl kaut kur un nebūsi pārbaudījis, tad var rasties problēmas. piem: select * from tabula where $id=$sadala; include('aaa'.$sadala); utt Link to comment Share on other sites More sharing options...
Recommended Posts