paulis Posted October 31, 2004 Report Share Posted October 31, 2004 lieta taada... es caur formas textboxu nododu ar POST kaut kaadu veertiibu. taa texboxa vaards ir izveidots automaatiski kaa nummurs: <form action="<? $_SERVER['PHP_SELF'];?>" method="POST" > <? for ($n=0;$n<10;$n++) print "<input type=\"text\" name=\"$n\" value=\"\" size=\"1\">"; ?> <input type="submit" name="submit" value="OK"> tagad ar $_POST veelos izvadiit lietotaaja ievadiitaas veertiibas. es izdaru taa: ... for($i=0;$i<10;$i++) echo $_POST['$i']; ... uz ekraana nekas netiek izvadiits. pilns teksts izskataas shaadi: <? $message = 'no'; if (isset($_POST['submit'])) { for($i=0;$i<10;$i++) echo $_POST['$i']; $message = 'yes'; } ?> <html> <body> <? if($message == 'no') {?> <form action="<? $_SERVER['PHP_SELF'];?>" method="POST" > <? for ($n=0;$n<10;$n++) print "<input type=\"text\" name=\"$n\" value=\"\" size=\"1\">"; ?> <input type="submit" name="submit" value="OK"><? }?> </body> </html> Jautaajums: vai var rakstiit $_POST['$i'], jeb mainiigais ieksh POST ir kaut kaa savaadaak jaanoraada, jeb ir savaadaaka metode kaa to realizeet? Link to comment Share on other sites More sharing options...
bubu Posted October 31, 2004 Report Share Posted October 31, 2004 (edited) Dažas kļūdas un ieteikumi: Ieteicams rakstīt <?php ... ?> nevis <? ... ?> <form action="<? $_SERVER['PHP_SELF'];?>" method="POST" > Nepareizi!! vajag <?php echo $_SERVER['PHP_SELF']; ?> for($i=0;$i<10;$i++) echo $_POST['$i']; Arī nepareizi! Vajag echo $_POST[$i]; Citādi tev visulaiku tiek meklēts POST mainīgais ar nosaukumu $i nevis 1, 2, .... Nav aizvērs (</form>) tags Man šāds skripts strādā bez problēmām: <?php $message = 'no'; if (isset($_POST['submit'])) { for($i=0;$i<10;$i++) echo $_POST[$i]; $message = 'yes'; } ?> <html> <body> <?php if($message == 'no') { ?> <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="POST" > <?php for ($n=0;$n<10;$n++) echo '<input type="text" name="'.$n.'" value="" size="1" />'; ?> <input type="submit" name="submit" value="OK" /> <?php } ?> </form> </body> </html> Edited October 31, 2004 by bubu Link to comment Share on other sites More sharing options...
paulis Posted October 31, 2004 Author Report Share Posted October 31, 2004 taa i vienmeer ... :) tikko esmu pazinjojis savu beedu pasaulei taa uzreiz pac rodu taas atrisinaajumu. karoche nevis $_POST['$i'] bet $_POST["$i"]; nu bet esmu paarliecinaats ka reiz jau to izmeeginaaju... hmmm Link to comment Share on other sites More sharing options...
Venom Posted November 1, 2004 Report Share Posted November 1, 2004 aizmirsti par $_POST["$i"], $_POST[$i] ir tas pats un labāk ja tev vienkārši vajag paskatīties, kas tiek nodots caur post vai kādu citu masīvu, var izmantot šādas konstrukcijas: print '<pre>'.print_r($_POST,1).'</pre>'; print '<pre>'.var_dump($_POST).'</pre>'; Link to comment Share on other sites More sharing options...
kirils Posted January 19, 2005 Report Share Posted January 19, 2005 nosauc tos formas mainiigos piemeeram a1, a2, a3. Link to comment Share on other sites More sharing options...
bubu Posted January 19, 2005 Report Share Posted January 19, 2005 kirils pamodies :) Link to comment Share on other sites More sharing options...
Recommended Posts