我正在修改我发现的一个脚本,该脚本检查它是否已安装并且
- 如果是,则显示登录屏幕
- 如果不是,它会显示安装屏幕。
在线安装但在 XAMPP 中无法正常工作
在 XAMPP 中,它安装正常,但是当进入管理员根目录时,会显示安装屏幕,如下所示。
注意:会话已经开始 - 忽略第 2 行 C:\xampp\htdocs\testa\admin\admin_config.php 中的 session_start()
注意:未定义变量:第 17 行 C:\xampp\htdocs\testa\main_admin.php 中的 dbhost
注意:未定义变量:第 17 行 C:\xampp\htdocs\testa\main_admin.php 中的 dbuname
注意:未定义的变量:第 17 行 C:\xampp\htdocs\testa\main_admin.php 中的 dbpass
注意:未定义变量:第 18 行 C:\xampp\htdocs\testa\main_admin.php 中的 dbname
我不明白为什么它可以在 Web 服务器上运行而不是在 XAMPP 中运行......你们有什么想法吗???
这是相关文件中的代码
配置文件
<?php
$dbhost="localhost"; //It is usually "localhost"
$dbuname="user"; //Database Username
$dbpass="pass"; //Database Password
$dbname="test"; //Database Name
?>
管理员/index.php
<?php
session_start();
header("Content-Type: text/html; charset=utf-8");
if (isset($_REQUEST["uname"]))
{
$uname=$_REQUEST["uname"];
$pass=$_REQUEST["pass"];
include('../config.php');
$db=mysql_connect($dbhost, $dbuname, $dbpass);
mysql_select_db($dbname, $db);
$check_security=mysql_query("select * from settings where admin_id='$uname' and password='$pass'", $db);
if ($rec=mysql_fetch_row($check_security))
{
header('Location: index.php');
$_SESSION['testa']="testa";
}
else
header('Location: index.php');
include('../main.php');
}
else
{
include('admin_config.php');
if (!isset($_SESSION['testa']))
{
echo ('<script language="JavaScript">
<!--
function CheckForm(formID) {
if (formID.uname.value == "") { alert("' . _ADMIN_ENTER_USERNAME . '");
formID.uname.focus(); return false; }
if (formID.pass.value == "") { alert("' . _ADMIN_ENTER_PASSWORD . '");
formID.pass.focus(); return false; }
return true;
}
//-->
</script> ');
echo ('<br><br><br><br><br><br><br><br><br>
<form method="POST" action="index.php" onSubmit="return CheckForm(this);" autocomplete="off">
<div align="center">
<table width="250" border="1" height="118" dir="' . $rtl_input . '"><tr>
<td height="22" colspan="2">
<p align="center"><font face="Tahoma" color="#FFFFFF"><span style="font-size: 9pt"><b>' . _ADMIN_SYSTEM_ALERT . '</b></span></font></td></tr><tr>
<td height="31">
<p align="' . $align . '"><font face="Tahoma" color="#FFFFFF"><span style="font-size: 9pt">' . _ADMIN_USERNAME . ':</span></font></td>
<td height="31">
<p align="left"><input type="text" name="uname" dir="ltr" size="20"></td></tr><tr>
<td height="31">
<p align="' . $align . '"><font face="Tahoma" color="#FFFFFF">
<span style="font-size: 9pt">' . _ADMIN_PASSWORD . ':</span></font>
</td><td height="31">
<p align="left">
<input type="password" name="pass" dir="ltr" size="20"></td></tr><tr>
<td colspan="2" valign="bottom" height="38">
<p align="center"><font face="Tahoma"><span style="font-size: 9pt"><input type="submit" value="' . _ADMIN_ENTER . '" name="B1"></span></font></p>
</td></tr></table>
</div>
</form>');
}
else
{
echo ('blahblahblah.................blah');
}
}
?>
</body>
</html>
main_admin.php
<?php
include('config.php');
include('jdf.php');
$db=mysql_connect($dbhost, $dbuname, $dbpass);
mysql_select_db($dbname, $db);
$result=mysql_query("select * from settings where id = '1'", $db);
if (!$result)
{
include('language/farsi.php');
echo ('<html dir="rtl">');
include('header_admin.php');
echo ('<SCRIPT LANGUAGE=JAVASCRIPT>
function dosubmit() {
document.forms[0].action = "users.php"
document.forms[0].method = "POST"
document.forms[0].submit()
}</SCRIPT><script language="JavaScript">
<!--
function CheckForm(formID) {
if (formID.admin_id.value == "") { alert("' . _ADMIN_INSTALL_ENTER_USERNAME . '");
formID.admin_id.focus(); return false; }
if (formID.password.value == "") { alert("' . _ADMIN_INSTALL_ENTER_PASSWORD . '");
formID.password.focus(); return false; }
if (formID.password_confirm.value == "") { alert("' . _ADMIN_INSTALL_ADD_USER_ENTER_CONFIRM_PASSWORD . '");
formID.password_confirm.focus(); return false; }
if (formID.password_confirm.value !== formID.password.value) { alert("' . _ADMIN_INSTALL_ADD_USER_PASSWORD_AND_CONFIRM_NOT_MATCH . '");
formID.password.focus(); return false; }
return true;
}
//-->
</script> ');
///////////////////////
echo ('<br /><br /><br /><br /><form method="POST" action="../install/" onSubmit="return CheckForm(this);"><div align="center">
<table border="1" width="600" dir="rtl">
******************************************************
************************************blahblablah*************************************
</table>
</div>
</form>
');
die();
//////////////End form
}
else
{
$rec=mysql_fetch_row($result);
$system_language=$rec[3];
include('language/' . $rec[3] . '.php');
if ($rec[4] == 1)
echo ('<html dir="rtl">');
else
echo ('<html>');
$result_rtl=mysql_query("select * from settings where id = '1'", $db);
$rtl_array=mysql_fetch_row($result_rtl);
if ($rtl_array[4] == 1)
{
$system_align=$align="right";
$system_rtl_input=$rtl_input="rtl";
}
else
{
$system_align=$align="left";
$system_rtl_input=$rtl_input="ltr";
}
include('header_admin.php');
}
//////////////bg
?>