Ownmen Posted August 18, 2008 Report Share Posted August 18, 2008 Sveiki, man ir šāds kods (atļaušos ielikt šeit nevis paset.php.lv, jo nav īpaši garš): <?php session_start(); $viens = 'viens'; $divi = 'divi'; if(isset($_GET['darbiiba']) and $_GET['darbiiba'] == 'login') { $i_1 = htmlspecialchars($_POST['viens']); $i_2 = htmlspecialchars($_POST['divi']); if(!empty($i_1) and !empty($i_2) and $i_1 == $viens and $i_2 == $divi) { $_SESSION['login'] = time(); } else { $nebuus = 'Nepareizi parametri!<br />'; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Ienākt</title> </head> <body> <?php if(!isset($_SESSION['login'])) { ?> <form method="post" action="index.php?darbiiba=login"> <?php if(isset($nebuus)) echo $nebuus; ?> <input type="text" name="viens" /><br /> <input type="password" name="divi" /><br /> <input type="submit" value="Ienākt" /> </form> <?php } else { echo 'logged in!'; } ?> </body> </html> Un es vēlējos vaicāt, ja es nezinu mainīgo $viens un $divi vērtības, vai ir kāda iespēja tos noskaidrot (izdrukāt ar javascript arlet utml.) vai kādi citādāk panākt, ka es ielogojos (izveidot sesiju login no kādas citas vietas utml), ja ir kāds veids, tad būtu ļoti jauki, ja Jūs to parādītu vai vismaz pateiktu. Neceru uz lielo atsaucību, bet nu mēģināts nav zaudēts... Link to comment Share on other sites More sharing options...
waplet Posted August 18, 2008 Report Share Posted August 18, 2008 ar ečo var izvadīt mainīgo~! Link to comment Share on other sites More sharing options...
Ownmen Posted August 18, 2008 Author Report Share Posted August 18, 2008 ar ečo var izvadīt mainīgo~! Jā, nu tik daudz es arī zinu, bet kā lai es viņus izvadu? man ir doti 2 input lauki, kurus izlaiž caur htmlspecialchars() Link to comment Share on other sites More sharing options...
waplet Posted August 18, 2008 Report Share Posted August 18, 2008 (edited) var definēt $viens = $_GETvaiPOST['viens'] $divi = $_GETvaiPOST['divi'] echo $viens " = viens" . $divi " = divi"; Par tām ķepiņām šaubos va pareizi Edited August 18, 2008 by waplet Link to comment Share on other sites More sharing options...
Ownmen Posted August 18, 2008 Author Report Share Posted August 18, 2008 (edited) labi, skaidrs ar tevi, laikam nesaprati, ka es vairs nevaru mainīt to kodu! pamēģini uzlikt uz localhost to kodu un izdrukāt mainīgos $viens un $divi, nemainot manis iedoto kodu! Kur tad Tu liksi to $viens = $_GETvaiPOST['viens'] $divi = $_GETvaiPOST['divi'] echo $viens " = viens" . $divi " = divi"; EDIT: konkretizēšu, ja man mainīgais $viens = 'lietotaajs'; ir šāds, tad man vajag kaut kur izdrukāt to vērtību "lietotaajs", tā pat ar $divi neliekod pirmaa posta kodā nevienu rindiņu, izmantojot tikai internetpārlūku utml. Edited August 18, 2008 by Ownmen Link to comment Share on other sites More sharing options...
Mikijs Posted August 18, 2008 Report Share Posted August 18, 2008 atradu kļūdiņu tev :) ir if(!empty($i_1) and !empty($i_2) and $i_1 == $viens and $i_2 == $divi) jābut f(!empty($i_1) and !empty($i_2) and $i_1 == htmlspecialchars($viens) and $i_2 == htmlspecialchars($divi)) vari izvadit Javascript <?php echo "<script> alert('1: ".str_replace("'", "\"", $i_1.")."\\n2: ".str_replace("'", "\"", $i_2.")."'); </script>"; ?> php <?php echo "1: $i_1<br>2:$i_2<br>"; echo("1: $i_1<br>2:$i_2<br>"); print("1: $i_1<br>2:$i_2<br>"); ?> Link to comment Share on other sites More sharing options...
waplet Posted August 18, 2008 Report Share Posted August 18, 2008 (edited) vari ielikt citā failā ar require(tavs kods.php) un tad to visu ko es iedevu! p.s. pastījos kodu , tev jau viņi ir definēti kā $i_1 un $i_2 , vnk requiro un izečo! Edited August 18, 2008 by waplet Link to comment Share on other sites More sharing options...
Ownmen Posted August 18, 2008 Author Report Share Posted August 18, 2008 (edited) laikam neviens īsti nesaprata situāciju, šiet būs darbībā: http://ownmen.namsolutions.co.uk/login/ Un kā šādā lapā izdrukāt tos $viens un $divi? Edited August 18, 2008 by Ownmen Link to comment Share on other sites More sharing options...
Mikijs Posted August 18, 2008 Report Share Posted August 18, 2008 (edited) njuu pieliec tur kur tev akcepte loginu ieliec $cepums="mylogin"; $vertiba=$viens."|".$divi; $vertiba=base64_encode($vertiba); setcookie($cepums, $vertiba, time()+3600); un lai paraditu dari ta $cepums="mylogin"; if($_COOKIE[$cepums]) { $vertiba=base64_decode($_COOKIE[$cepums]); setcookie($cepums, $vertiba, time()+3600); $ex=explode("|", $vertiba); $viens=$ex[0]; $divi=$ex[1]; echo "Viens: $viens"; echo "Divi: $divi"; } un kad logojies ara vienkarsi setcookie($cepums, ""); Edited August 18, 2008 by Mikijs Link to comment Share on other sites More sharing options...
Ownmen Posted August 18, 2008 Author Report Share Posted August 18, 2008 bet kā lai es viņus tur ielieku, ja nevaru labot failu? Link to comment Share on other sites More sharing options...
Mikijs Posted August 18, 2008 Report Share Posted August 18, 2008 nu bet ka .. lai tu varetu dabut kaut ko ara, tev ir japamaina kods un lai to izdaritu tev ir jāvar labot failu. Link to comment Share on other sites More sharing options...
waplet Posted August 18, 2008 Report Share Posted August 18, 2008 Man rādās you dont have permission , man liekas nekādi nevar bez labošanas , vēl ar kaut kādiem tur fopen no cita faila un fwrite un tiem sūdiņiem! Link to comment Share on other sites More sharing options...
Mikijs Posted August 18, 2008 Report Share Posted August 18, 2008 ir jau vēl "file_get_contents();" Link to comment Share on other sites More sharing options...
Aleksejs Posted August 18, 2008 Report Share Posted August 18, 2008 jautājums: Vai ir pieļaujams tajā pašā mapē izveidot citu failu? Link to comment Share on other sites More sharing options...
Ownmen Posted August 18, 2008 Author Report Share Posted August 18, 2008 (edited) es samainiiju linku vienkaarši lai neložņā pa manā mapē :D Aleksejs: nav gan ;( p.s. Vai ir iespējams include() pilnu URL no address bar? Edited August 18, 2008 by Ownmen Link to comment Share on other sites More sharing options...
Recommended Posts