290184 Posted April 4, 2007 Share Posted April 4, 2007 i want to save the content of a textarea in a file in php.the code i tried is: <? if ($submit) { //nese butoni eshte ruaj if ($submit=="Ruaj") { $your_data=($HTTP_POST_VARS['comments']) $era = "beni.txt"; $fh = fopen($era, 'w') or die("Can't open file"); fwrite($fh, $your_data); fclose($fh);}} ?> could you tell me where is the problem? ??? Link to comment https://forums.phpfreaks.com/topic/45570-files-in-php/ Share on other sites More sharing options...
trq Posted April 4, 2007 Share Posted April 4, 2007 Where have you defined $submit? If its comming through a form, its most likely in $_POST['submit']. Link to comment https://forums.phpfreaks.com/topic/45570-files-in-php/#findComment-221261 Share on other sites More sharing options...
290184 Posted April 4, 2007 Author Share Posted April 4, 2007 yes submit is in a form,i tried it like you said but it doesn't work. Link to comment https://forums.phpfreaks.com/topic/45570-files-in-php/#findComment-221315 Share on other sites More sharing options...
kenrbnsn Posted April 4, 2007 Share Posted April 4, 2007 use $_POST instead of $HTTP_POST_VARS. At the start of the script put in the lines: <?php if (isset($_POST['submit'])) echo '<pre>' . print_r($_POST,true) . '</pre>'; ?> This will dump what is being passed to your script from the form. Ken Link to comment https://forums.phpfreaks.com/topic/45570-files-in-php/#findComment-221330 Share on other sites More sharing options...
290184 Posted April 5, 2007 Author Share Posted April 5, 2007 thanks ken but is the same,the content of the files doesn't change. the code: <? if (isset($_POST['submit'])) echo '<pre>' . print_r($_POST,true) . '</pre>'; { if ($_POST['submit']=="Save") { $your_data = $_POST['comments'];/ comments is the name of the textbox $era = "beni.txt"; $fh = fopen($era, 'w') or die("Can't open file"); fwrite($fh, $your_data); fclose($fh);}} ?> is it allright? Link to comment https://forums.phpfreaks.com/topic/45570-files-in-php/#findComment-222142 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.