Hello! In general, the task is such that somewhere, I crookedly get data from the form that I can not write to the file.
There is html file
<div class="modal fade" id="sendMsgToPhp" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> <div class="modal-dialog" role="document"> <div class="modal-content"> <form> <div class="form-group"> <label for="theme">Тема</label> <input type="text" name="theme" class="form-control" id="theme" placeholder="Тема"> </div> <div class="form-group"> <label for="time">Время</label> <input type="text" name="time" class="form-control" id="time" placeholder="Время"> </div> <button type="submit" class="btn btn-default">Отправить</button> <div class="success" style="display: none;"> <p>Добавлено!</p> </div> </form> </div> </div> </div> Taken with jquery
$(document).ready(function () { $("#sendMsgToPhp").submit(function (event) { event.preventDefault(); $.ajax({ type: "POST", url: "../php_scripts/update.php", data: $("#sendMsgToPhp").serialize(), success: function () { $('.success').delay(600).fadeIn(1000); } }); }); }); Now we write to the file via php
<?php $theme = $_POST['theme']; $time = $_POST['time']; $today = $theme . " " . $time; $fh = fopen("testfile.txt", 'r+') or die("Сбой открытия файла"); fseek($fh, 0, SEEK_END); fwrite($fh, $today) or die("Сбой записи в файл"); fclose($fh); ?>
echo $today;// did something appear? - Peresada