eronmezza Posted August 28, 2007 Share Posted August 28, 2007 please help someone, might be lame mistake. here's the cde: <body> <form> <p><span class="style1">Versenyidőpont neve</span><span class="style2">:</span> <input type="text" size="12" maxlength="12" name="Nam"> </p> <p> </p> <input type="submit" value="Küldés" name="submit"> </form> <? $outpu = $_POST['Nam'] . "|"; $Nam = $_POST["Nam"]; if (!isset($_POST['submit'])) { } else { $filenam="idopontok.txt"; $filetartal = fopen($filenam,"a+"); fwrite($filetartal, $outpu); } ?> </body> Link to comment https://forums.phpfreaks.com/topic/67041-solved-fwrite-not-working/ Share on other sites More sharing options...
trq Posted August 28, 2007 Share Posted August 28, 2007 And the problem is? Link to comment https://forums.phpfreaks.com/topic/67041-solved-fwrite-not-working/#findComment-336200 Share on other sites More sharing options...
eronmezza Posted August 28, 2007 Author Share Posted August 28, 2007 doesnt write in the file Link to comment https://forums.phpfreaks.com/topic/67041-solved-fwrite-not-working/#findComment-336202 Share on other sites More sharing options...
eronmezza Posted August 28, 2007 Author Share Posted August 28, 2007 so hey anyone please can you see what's wrong...? might be here: $outpu = $_POST['Nam'] . "|"; Link to comment https://forums.phpfreaks.com/topic/67041-solved-fwrite-not-working/#findComment-336465 Share on other sites More sharing options...
lemmin Posted August 28, 2007 Share Posted August 28, 2007 Do you get an error or just a blank file? Is your if condition executing the code you want? try putting an echo statement above the fopen and see if something gets echoed. If you think it is the string, try using a constant string to test it like, fwrite($handle, "test"). Link to comment https://forums.phpfreaks.com/topic/67041-solved-fwrite-not-working/#findComment-336474 Share on other sites More sharing options...
eronmezza Posted August 28, 2007 Author Share Posted August 28, 2007 seems like it doesnt get to the if statement because i put an echo after else and it doesnt show up... Link to comment https://forums.phpfreaks.com/topic/67041-solved-fwrite-not-working/#findComment-336483 Share on other sites More sharing options...
eronmezza Posted August 28, 2007 Author Share Posted August 28, 2007 no error, no echo after the ifelse statement, no write in the file here: <body> <form> <p><span class="style1">Versenyidőpont neve</span><span class="style2">:</span> <input type="text" size="12" maxlength="12" name="Nam"> </p> <p> </p> <input type="submit" value="Küldés" name="submit"> </form> <? $outpu = $_POST['Nam'] . "|"; $Nam = $_POST["Nam"]; if (!isset($_POST['submit'])) { } else { $filenam="idopontok.txt"; echo "tilláromhajj"; $filetartal = fopen($filenam,"a+"); fwrite($filetartal, "tilláromhajj"); } ?> can't the problem be the $_POST('submit') part? Link to comment https://forums.phpfreaks.com/topic/67041-solved-fwrite-not-working/#findComment-336492 Share on other sites More sharing options...
lemmin Posted August 28, 2007 Share Posted August 28, 2007 Yes. Most likely, that variable is not set. Link to comment https://forums.phpfreaks.com/topic/67041-solved-fwrite-not-working/#findComment-336494 Share on other sites More sharing options...
eronmezza Posted August 28, 2007 Author Share Posted August 28, 2007 so what should i do? in an other part i didnt make a var for it still it works. what's the difference? Link to comment https://forums.phpfreaks.com/topic/67041-solved-fwrite-not-working/#findComment-336497 Share on other sites More sharing options...
lemmin Posted August 28, 2007 Share Posted August 28, 2007 Change this: if (!isset($_POST['submit'])) { } else { to: if (!isset($_POST['submit'])) { print_r($_POST); } else { and see what happens. Link to comment https://forums.phpfreaks.com/topic/67041-solved-fwrite-not-working/#findComment-336499 Share on other sites More sharing options...
eronmezza Posted August 28, 2007 Author Share Posted August 28, 2007 funnily enough a text saying "Array()" is written under the submit button. ??? as for the script it still isnt working. Link to comment https://forums.phpfreaks.com/topic/67041-solved-fwrite-not-working/#findComment-336511 Share on other sites More sharing options...
eronmezza Posted August 28, 2007 Author Share Posted August 28, 2007 quite weird isnt it Link to comment https://forums.phpfreaks.com/topic/67041-solved-fwrite-not-working/#findComment-336514 Share on other sites More sharing options...
lemmin Posted August 28, 2007 Share Posted August 28, 2007 Your <form> object doesn't have any parameters. put method=POST and action=[yourfile.php]. Link to comment https://forums.phpfreaks.com/topic/67041-solved-fwrite-not-working/#findComment-336520 Share on other sites More sharing options...
freeloader Posted August 28, 2007 Share Posted August 28, 2007 You might want to try and tell the form where to send its data to Something like: <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> Link to comment https://forums.phpfreaks.com/topic/67041-solved-fwrite-not-working/#findComment-336524 Share on other sites More sharing options...
eronmezza Posted August 28, 2007 Author Share Posted August 28, 2007 far too right mate, thanks for your help. solved! Link to comment https://forums.phpfreaks.com/topic/67041-solved-fwrite-not-working/#findComment-336528 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.