So ändern Sie den TXT-Wert: Verwenden Sie die Umschalttaste
P粉769413355
P粉769413355 2023-09-13 16:52:32
0
1
733

Ich möchte wissen, wie ich meine Datei „database.txt“ bearbeiten kann, indem ich die Schaltfläche ein- und ausschalte. Ich fange gerade erst an zu lernen und hoffe zu verstehen, wie ich es umsetzen kann.

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'])) {

}

?>

Dies ist eine Weiterleitung zum Aktivieren oder Deaktivieren der Seite

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粉769413355
P粉769413355

Antworte allen(1)
P粉090087228

我已经尝试了几次不同的方法,无法确定如果未启用,则值为“off”,如果启用则值为“on”。对不起,这可能看起来很简单,但我刚刚开始。

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');


}
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage