FT3 Posted February 9, 2010 Report Share Posted February 9, 2010 Labdien te tada lieta kur man jaieliek kodu echo "Neizdevas" Lai vinu raditu kad nau aizpilditi input lauki ? rekur kods ! <?function add(){ ?> <form action="" method="POST" > <table width="100%" cellspacing="3" cellpadding="0"> <tr><td><b> title 1: </b></td><td> <input type="text" name="title1"></td></tr> <tr><td><b> title 2: </b></td><td> <input type="text" name="title2"></td></tr> <tr><td><input type="submit" name="submit" value="Pievienot"></td><td> </table> </form> <? } if ($_POST['submit']) { $title1 = $_POST['title1']; $title2 = $_POST['title2']; if (($title1 != "") && ($title2 != "")) { ?> <b>Done!</b><? echo "<meta http-equiv='refresh' content='2;url=java script: history.go(-1)'>"; mysql_query("INSERT INTO titles (title1, title2) VALUES('$title1', '$title2') ") or die(mysql_error()); }}else{add();} ?> Visska esmu meginajis bet neka nesanak ;/ Iepriekš paldies ! :) Quote Link to comment Share on other sites More sharing options...
Pentiums Posted February 9, 2010 Report Share Posted February 9, 2010 Kautkāds murgains tev tas kods... bet te pavediens... if($_POST['zaraza'] != '') { turpinam... } else { daram to kas jādara ja `zaraza` ir tukša... } Quote Link to comment Share on other sites More sharing options...
rATRIJS Posted February 9, 2010 Report Share Posted February 9, 2010 (edited) my eyes!!!!!!! Saac ar koda struktureeshanu...un tavs echo 'Neizdevas' tur butu mazaka problema...shobriid vinju vari baazt visur un taapat shaubos, ka kaut kas straadaas kaa paredzeets... Ak jaa - un es to visu dzeest un saaktu no 0...ieprieksh pamaacoties. Edited February 9, 2010 by rATRIJS Quote Link to comment Share on other sites More sharing options...
FT3 Posted February 9, 2010 Author Report Share Posted February 9, 2010 kods nau murgains , man viss perfecti strada ! ;]] Quote Link to comment Share on other sites More sharing options...
2easy Posted February 9, 2010 Report Share Posted February 9, 2010 (edited) rATRIJ, tas kods ir kruts! :D }}else{add();} -> }else echo "Neizdevas";}else{add();} Edited February 9, 2010 by 2easy Quote Link to comment Share on other sites More sharing options...
FT3 Posted February 9, 2010 Author Report Share Posted February 9, 2010 2easy , pld teu ;]] viss iet ;] ka tu kautk0 saprati maneya murga ? :D Quote Link to comment Share on other sites More sharing options...
2easy Posted February 9, 2010 Report Share Posted February 9, 2010 (edited) es kādreiz (tikai samērā neilgu brīdi) katru funkciju rakstīju vienā rindiņā. bet pēc tam pārdomāju un sapratu, ka tas ir mazliet par traku, un sāku rakstīt nedaudz plašāk pa vairākām rindiņām :)) iemesls par labu plašākai/izvērstākai koda raktībai bija lasāmība un loģisko bloku uztvere vnk dažādi līkloči ir izieti ideālā koda meklējumos... ;) Edited February 9, 2010 by 2easy Quote Link to comment Share on other sites More sharing options...
FT3 Posted February 9, 2010 Author Report Share Posted February 9, 2010 sk , paldies teu ;]] Quote Link to comment Share on other sites More sharing options...
rATRIJS Posted February 9, 2010 Report Share Posted February 9, 2010 (edited) Es pacentos (padariiju saprotamaaku arii): <?php /** * Probleemas: * - nosaukums neatbilst tam ko f-ja dara. * - es neatbalstu f-jas, kas tikai izvada kaut ko HTML'iigu - tam ir templates. */ function add() { ?> <form action="" method="POST" > <table width="100%" cellspacing="3" cellpadding="0"> <tr><td><b> title 1: </b></td><td> <input type="text" name="title1"></td></tr> <tr><td><b> title 2: </b></td><td> <input type="text" name="title2"></td></tr> <tr><td><input type="submit" name="submit" value="Pievienot"></td><td> </table> </form> <?php } ?> <?php if($_POST['submit']) { /** * Probleemas ar sho rindinju: * - potenciaali biistama, jo netiek eskeipots strings, lai vinjsh nebuutu SQL injekciju ievainojams * - kapeec nosaukumaa ir 1? * - dabuusi E_NOTICE liimenja warning'u ja kaads nepados sho lauku */ $title1 = $_POST['title1']; /** * Probleemas ar sho rindinju: * - tas pats ar SQL injekcijaam * - kapeec nosaukumaa ir 2? Neko neizsakoshi... * - tas pats par E_NOTICE */ $title2 = $_POST['title2']; if(empty($title1) or empty($title2)) { echo 'Neizdevaas (no shit)!'; add(); } else { /** * Probleemas: * - SQL ievainojamiibas FTW */ mysql_query("INSERT INTO titles (title1, title2) VALUES('$title1', '$title2') ") or die(mysql_error()); /** * Kaada jeega izvadiit shaadu mazu tekstinju uz 2s? Vismaz uzstilot... */ echo 'Done! (neticu)'; /** * Probleemas: * - javascript raksta kopaa * - shis buutu jaaliek ieksh <head>. Neizskataas, ka tas buus ieveerots. */ echo "<meta http-equiv='refresh' content='2;url=java script: history.go(-1)'>"; } } else { add(); } ?> Edited February 9, 2010 by rATRIJS Quote Link to comment Share on other sites More sharing options...
EdgarsK Posted February 10, 2010 Report Share Posted February 10, 2010 2easy - vai tava 'perfektaja koda' ietilpst short tags? ja ne tad es nedraudzesos ar tevi =D es nez kapec, bet jau vairak ka pusgadu nevaru normali rakstit kodu, ja ir <?php .. ?> man tas 'php' vislaik lec acis un trauce, tapec viss kods sastav no <?..?> Teiksim iedomajamies shadu formu <form method="<?php=$method?>"> action="<?php=$action?>"> Login:<br/> <input type="text" name="<?php=$lname?>" value="<?php=$pname?>"/><br/> Pass:<br/> <input type="text" name="<?php=$lpass?>" value="<?php=$ppass?>"/><br/> <input type="submit" name="<?php=$lsub?>" value="Okej"/> </form> kad ta vieta tu vari visu kautnedaudz samazinat un novakt to visu uzkritoshos <?php <form method="<?=$method?>"> action="<?=$action?>"> Login:<br/> <input type="text" name="<?=$lname?>" value="<?=$pname?>"/><br/> Pass:<br/> <input type="text" name="<?=$lpass?>" value="<?=$ppass?>"/><br/> <input type="submit" name="<?=$lsub?>" value="Okej"/> </form> Jūsu domas par šo? Quote Link to comment Share on other sites More sharing options...
2easy Posted February 10, 2010 Report Share Posted February 10, 2010 tavai zināšanai šis ir parse error <?php=$lname?> Quote Link to comment Share on other sites More sharing options...
EdgarsK Posted February 10, 2010 Report Share Posted February 10, 2010 ja? :D nezinaju Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.