brekulis Posted November 26, 2006 Report Share Posted November 26, 2006 Nan parādās tikai virsraksts, lauks kur ievadīt vārdu un submit poga, vienalga raksta vai neraksta vārdu spiežot submit pogu nekas nenotiek! Tā ir koda kļuda? <?php if (isset($submit)){ if (empty($vards)){ print ("Tu neesi ierakstījis savu vārdu!\n"); } else{ print ("$vards, Tu nospiedi formas apstiprināšanas pogu.\n"); } } else{ print ("<form action=\"isset_func.php\" method=\"post\">\n"); print ("Ievadi savu vārdu:<br><input type=\"text\" name=\"vards\"><br>\n"); print ("<input type=\"submit\" name=\"submit\" value=\"apstiprināt\">\n"); print ("</form>"); } ?> Link to comment Share on other sites More sharing options...
Delfins Posted November 26, 2006 Report Share Posted November 26, 2006 apnika jau.... register_globals problema... pameklē forumā. neesi pirmais. Link to comment Share on other sites More sharing options...
Val Posted November 26, 2006 Report Share Posted November 26, 2006 Domā, ko raksti ;) <?php //-------- $submit = $_POST['submit']; $vards = $_POST['vards']; //----------- if (isset($submit)){ if (empty($vards)){ print ("Tu neesi ierakstījis savu vārdu!\n"); } else{ print ("$vards, Tu nospiedi formas apstiprināšanas pogu.\n"); } } else{ print ("<form action=\"isset_func.php\" method=\"post\">\n"); print ("Ievadi savu vārdu:<br><input type=\"text\" name=\"vards\"><br>\n"); print ("<input type=\"submit\" name=\"submit\" value=\"apstiprināt\">\n"); print ("</form>"); } ?> Link to comment Share on other sites More sharing options...
brekulis Posted November 26, 2006 Author Report Share Posted November 26, 2006 (edited) Viss sanaak! Paldies! Edited November 26, 2006 by brekulis Link to comment Share on other sites More sharing options...
brekulis Posted November 26, 2006 Author Report Share Posted November 26, 2006 Vēlviens jautājums! Es izveidoju vēlvienu ievades lauku - paroli un pie if(empy($name)||($pwd)) man notiek sekojoša problēma Ja ievada tikai paroli viņš man izvada to ko man vajaga, bet ja ievada vārdu nez kapēc forma izpildās! Link to comment Share on other sites More sharing options...
bubu Posted November 26, 2006 Report Share Posted November 26, 2006 Gadījumā negribēji rakstīt šādi: if (empy($name) || empty($pwd)) Link to comment Share on other sites More sharing options...
brekulis Posted November 26, 2006 Author Report Share Posted November 26, 2006 droši vine ka gribēju, thanks Link to comment Share on other sites More sharing options...
Val Posted November 26, 2006 Report Share Posted November 26, 2006 if (empty($vards) || empty($pwd)) Link to comment Share on other sites More sharing options...
brekulis Posted November 26, 2006 Author Report Share Posted November 26, 2006 (edited) Šādā pašā veidā var likt kaut vai 10 mainīgos? Piemeram: if (empty($vards) || empty($pwd) || empty($mail) || empty($zirgs)))> Edited November 26, 2006 by brekulis Link to comment Share on other sites More sharing options...
Val Posted November 26, 2006 Report Share Posted November 26, 2006 Jā, tikai tev beigās aizverošās iekavas pa daudz. Link to comment Share on other sites More sharing options...
Delfins Posted November 26, 2006 Report Share Posted November 26, 2006 $fields = Array('name','surname'); $emptyFields = Array(); foreach ($fields AS $fieldName) { if (empty($_POST[$fieldName])) { $emptyFields[] = $fieldName; } } if (!empty($emptyFields)) { print 'Lauki <strong>'.implode(', ',$emptyFields).'</strong> nav aizpildīti!' } else { // viss ok } Link to comment Share on other sites More sharing options...
brekulis Posted November 26, 2006 Author Report Share Posted November 26, 2006 Oj, shitas jau man bishku par sarežģītu! Link to comment Share on other sites More sharing options...
Val Posted November 26, 2006 Report Share Posted November 26, 2006 Liekas, ka Delfins kodā šī if (!empty($emptyFields)) rindai tieši otrādāk vajag, kad ir tukšs lauks, tad tieši izdrukā paziņojumu tb if (empty($emptyFields)) Link to comment Share on other sites More sharing options...
andrisp Posted November 26, 2006 Report Share Posted November 26, 2006 Val, nē. $emptyFields saturēs tos, kas nav aizpildīti. Tātad ja nav tukš (!empty), tad visi lauki nav aizpildīti. Link to comment Share on other sites More sharing options...
Val Posted November 26, 2006 Report Share Posted November 26, 2006 ok, skaidrs. Es tā ātrumā izlasīju, ka ja tukšs lauks, tad izmet to tekstu ;) Link to comment Share on other sites More sharing options...
Recommended Posts