-2

i've connected this code with html form button

<?php

$old= "/Full"; $new= "/only";

if ( $_POST ) {
    $old= $new;
    header('Location: $old'); } 
else {
    header('Location: $old');

i want to save the inputs without sql some thing like Replacing the code with save but without database does it possible ?

my old question to understand Path changer in Admin Dashboard

reko beko
  • 86
  • 1
  • 1
  • 10

1 Answers1

1

Based off of the conversation in the comments, you could just put it in a .json file:

paths.json

{
    "oldPath": "/Full",
    "newPath": "/only"
}

your-php-file.php

<?php

// Decode the JSON into a PHP array
$json = json_decode(file_get_contents("paths.json"), true);

// If a POST request was submitted
if ( $_POST ) {
    // Redirect the user to the newPath
    header('Location: ' . $json['newPath']); 
} else {
    // Otherwise redirect them to the old path
    header('Location: ' . $json['oldPath']);
}

file_get_contents() MUST be enabled and configured properly in your PHP configuration.

robere2
  • 1,689
  • 2
  • 16
  • 26