-6ren">
gpt4 book ai didi

php - 如何将 MySQL 数据库和用户从表单添加到配置文件

转载 作者:行者123 更新时间:2023-11-30 23:08:09 25 4
gpt4 key购买 nike

我在 install/install.php 中有这个表单:

<form method="POST" action="installing.php" onSubmit="return validatedb();" id="installform">
<div class="form">
<div class="initem">
<div class="dib name">Database Host</div>
<div class="dib value"><input type="text" name="dbhost" value="<?= $preDbHost ?>" /></div>
</div>
<div class="initem">
<div class="dib name">Database Name</div>
<div class="dib value"><input type="text" name="dbname" value="<?= $preDbName ?>" /></div>
</div>
<div class="initem">
<div class="dib name">Database User</div>
<div class="dib value"><input type="text" name="dbuser" value="<?= $preDbUser ?>" /></div>
</div>
<div class="initem">
<div class="dib name">Database Pass</div>
<div class="dib value"><input type="text" name="dbpass" value="<?= $preDbPass ?>" /></div>
</div>
</div>
<div class="stepper bbr">
<div class="fll">Step 1/2 : Database Settings</div>
<div class="flr"><input type="submit" value="Validate & Continue" class="btl bbr"/></div>
<div class="cls"></div>
</div>
</form>

在 inc/config.inc.php 中这段代码:

<?php

// Error Reporting
@error_reporting(E_ALL ^ E_NOTICE);


/// Database Settings ///
define('DB_NAME', ''); // MySQL database name
define('DB_USER', ''); // MySQL database user
define('DB_PASSWORD', ''); // MySQL database password
define('DB_HOST', 'localhost'); // MySQL database host name (in most cases, it's localhost)


if (isset($_SESSION['userid']) && is_numeric($_SESSION['userid']))
{
$userid = (int)$_SESSION['userid'];
}

define('Jobfia_ROOT', dirname(__FILE__) . '/');
define('Jobfia_PAGE', TRUE);

require_once(Jobfia_ROOT."db.inc.php");
require_once(Jobfia_ROOT."functions.inc.php");

if (!defined('is_Setup'))
{
require_once(Jobfia_ROOT."siteconfig.inc.php");
}

?>

如何通过php在数据库设置的inc/config.inc.php中添加表单值,同时验证它们是否为真实值?

最佳答案

导入文件 inc/config.inc.php 在文件 install/install.php比

$DB_NAME
$DB_USER
$DB_PASSWORD
$DB_HOST

可以直接访问

关于php - 如何将 MySQL 数据库和用户从表单添加到配置文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20956771/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com