2017-09-02 127 views
-2

我已经连接此代码的HTML表单按钮替换PHP代码与if语句

我要保存输入,而不SQL中的一些东西像保存,但没有数据库做它更换 码可能吗?

我的老问题,了解Path changer in Admin Dashboard

+1

SQL是一种数据库。如果您没有数据库,则无法将某些内容保存到数据库中。 – bugfroggy

+0

@bugfroggy还有另一种类型的数据库,像文件 –

+0

只是文件与项目文件ican保存在它吗? –

回答

1

根据关中评论的谈话,你可以把它放在一个.json文件:

paths.json

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

您-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()必须在您的PHP配置中正确启用和配置。

+0

如果我按下按钮重定向将被保存,直到我按下相反的按钮? –

+0

所以标题将永远是/只有永远 –

+1

否。如果你到这个PHP页面,如果一个表单被提交(或以其他方式发送POST请求),那么你将被发送到'/ only'。否则它会发送给你'/ Full'。 – bugfroggy