Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- $id = (int) $_GET['id'];
- $file = file('data.txt');
- if ($id > 0) {
- for ($i = 0; $i < count($file); $i++) {
- $exp = explode('@', $file[$i]);
- if ($exp[0] == $id) {
- $reWrite = 1;
- unset($file[$i]);
- break;
- }
- }
- }
- if ($reWrite == 1) {
- file_put_contents('data.txt', "");
- foreach ($file as $value) {
- file_put_contents('data.txt', $value, FILE_APPEND);
- }
- $_SESSION['_success'] = 'Записът е изтрит !';
- header("Location: index.php");
- } else {
- $_SESSION['_error'] = 'Не съществува такъв запис!';
- header("Location: index.php");
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment