I want to know how to edit my database.txt file by switching the button. I'm just starting to learn and I hope to understand how to implement it.
Database.txt
1|on|on|on|;
setting.php
<?php <label class="switch"> <input type="checkbox" name="switcha"> <div class="slider"></div> </label> if (isset($_POST['switcha'])) { } <label class="switch"> <input type="checkbox" name="switchb"> <div class="slider"></div> </label> if (isset($_POST['switchb'])) { } <label class="switch"> <input type="checkbox" name="switchc"> <div class="slider"></div> </label> if (isset($_POST['switchc'])) { } ?>
This is a redirect to enable or disable the page
redirection.php
<?php $data = file_get_contents("database.txt"); $rows = explode("|", $data); $redirectiona = $rows[1]; $redirectionb = $rows[2]; $redirectionc = $rows[3]; if($redirectiona == "on"){ header('location: 1.php'); exit(); } if($redirectionb == "on"){ header('location: 2.php'); exit(); } if($redirectionc == "on"){ header('location: 3.php'); exit(); } ?>
P粉0900872282023-09-14 13:16:41
I've tried a few different things and can't figure out what the value is "off" if not enabled and "on" if enabled. Sorry this may seem simple but I'm just getting started.
if (isset($_POST['switcha'])) { $data = file_get_contents("database.txt"); $rows = explode("|", $data); $redirectiona = $rows[1]; $redirectionb = $rows[2]; $redirectionc = $rows[3]; $content = str_replace("1|on|$redirectionb|$redirectionc|",file_get_contents($data)); saveTxt($data,$content,'w'); }