b0lero Posted June 27, 2015 Share Posted June 27, 2015 Hey gay i did something but i don't know how to finish it There is the code <?php if(isset($_POST['formSubmit'])) { $aPeriod = $_POST['formPeriod']; if(!isset($aPeriod)) { echo("<p>You didn't select period!</p>\n"); } else { $nPeriod = count($aPeriod); echo("<p>The curent period is: $nPeriod : "); for($i=0; $i < $nPeriod; $i++) { echo($aPeriod[$i] . " "); } echo("</p>"); } } ?> <form action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="post"> <label for='formPeriod[]'>Select the period:</label><br> <select name="formPeriod[]"> <option value="Vegetative">Vegetative</option> <option value="Flowering">Flowering</option> </select><br> <input type="submit" name="formSubmit" value="Submit" > </form> all i want to do is to save this submit into txt file so i don't have to submit the period in every visit into the web site any ideas ? Quote Link to comment https://forums.phpfreaks.com/topic/297062-select-period-coding-help/ Share on other sites More sharing options...
Ch0cu3r Posted June 27, 2015 Share Posted June 27, 2015 (edited) Have go at using the following functions file_put_contents and implode Edited June 27, 2015 by Ch0cu3r Quote Link to comment https://forums.phpfreaks.com/topic/297062-select-period-coding-help/#findComment-1515088 Share on other sites More sharing options...
b0lero Posted June 27, 2015 Author Share Posted June 27, 2015 unforchantly not Quote Link to comment https://forums.phpfreaks.com/topic/297062-select-period-coding-help/#findComment-1515093 Share on other sites More sharing options...
b0lero Posted June 27, 2015 Author Share Posted June 27, 2015 unforchantly not I just start learning php coding still expect book on my language so will be easy for me to understand Quote Link to comment https://forums.phpfreaks.com/topic/297062-select-period-coding-help/#findComment-1515095 Share on other sites More sharing options...
Zane Posted June 27, 2015 Share Posted June 27, 2015 What language do you speak? Quote Link to comment https://forums.phpfreaks.com/topic/297062-select-period-coding-help/#findComment-1515096 Share on other sites More sharing options...
b0lero Posted June 27, 2015 Author Share Posted June 27, 2015 What language do you speak? Bulgarian Quote Link to comment https://forums.phpfreaks.com/topic/297062-select-period-coding-help/#findComment-1515099 Share on other sites More sharing options...
Zane Posted June 27, 2015 Share Posted June 27, 2015 http://php.net/manual/bg/ Quote Link to comment https://forums.phpfreaks.com/topic/297062-select-period-coding-help/#findComment-1515103 Share on other sites More sharing options...
b0lero Posted June 27, 2015 Author Share Posted June 27, 2015 http://php.net/manual/bg/ I chek that already onlty the navigation is on bulgarian language the rest is english Quote Link to comment https://forums.phpfreaks.com/topic/297062-select-period-coding-help/#findComment-1515110 Share on other sites More sharing options...
Ch0cu3r Posted June 28, 2015 Share Posted June 28, 2015 The two functions I linked to, their documentation is available in Bulgarian here http://php.net/manual/bg/function.file-put-contents.php http://php.net/manual/bg/function.implode.php Quote Link to comment https://forums.phpfreaks.com/topic/297062-select-period-coding-help/#findComment-1515133 Share on other sites More sharing options...
b0lero Posted June 28, 2015 Author Share Posted June 28, 2015 (edited) OK almost understand what file_put_contents work , $file = __DIR__."/test.txt"; file_put_contents($file, "Hello, World!"); echo file_get_contents($file); i also find in diferent format <?php // Open the text file $f = fopen("test.txt", "w"); // Write text line fwrite($f, "PHP is fun!"); // Close the text file fclose($f); // Open file for reading, and read the line $f = fopen("test.txt", "r"); echo fgets($f); fclose($f); ?> witch is same function , but still the problem its same i can't connect it to my code witch alredy have or i need to do something totali differend Edited June 28, 2015 by b0lero Quote Link to comment https://forums.phpfreaks.com/topic/297062-select-period-coding-help/#findComment-1515176 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.