所以这段代码的目的是:如果 config2.php 文件中有数据,那么你可以登录,但如果没有(ELSE),那么你需要通过数据库连接安装程序。我尝试了几种不同的变体和技术,但没有实际工作。我将显示两个按钮,或者甚至认为信息已发布到 config2.php 文件中的一个按钮...
$installation = 'config/config2.php';
if ( strpos(file_get_contents($installation),$_GET['host']) !== true) {
echo "<br><p style='text-align: center'><strong>Lets get started, press the login button below to begin!</strong> <br><br>
<a href='#myModal' class='btn btn-primary' data-toggle='modal'>LOGIN</a></p> ";
echo "<div id='myModal' class='modal hide fade' tabindex='-1' role='dialog' aria-labelledby='myModalLabel' aria-hidden='true'>
<div class='modal-header'>
<button type='button' class='close' data-dismiss='modal' aria-hidden='true'>×</button>
<h3 id='myModalLabel'>User Login</h3>
</div>
<div class='modal-body'>
<form action='login.php' method='post'>
<table>
<tr style='text-align: center'>
<td>Username: </td>
<td><input type='text' name='email' placeholder='Your Simple Invoices Username' /></td>
</tr>
<tr style='text-align: center'>
<td>Password: </td>
<td><input type='password' name='password' placeholder='Password' /></td>
</tr>
</table>
</div>
<div class='modal-footer'>
<button class='btn btn-danger' data-dismiss='modal' aria-hidden='true'>Close</button>
<input class='btn btn-success' type='submit' name='submit' value='Login' />
</div>
</div>";
} else ( strpos(file_get_contents($installation),$_GET['host']) !== false); {
echo "<br><br>";
echo "<p style='text-align: center'>You need to install to use it!</p>";
echo "<p style='text-align: center'><a href='#myModal2' class='btn btn-success' data-toggle='modal'>INSTALL!</a></p>";
echo "<div id='myModal2' class='modal hide fade' tabindex='-1' role='dialog' aria-labelledby='myModalLabel' aria-hidden='true'>
<div class='modal-header'>
<button type='button' class='close' data-dismiss='modal' aria-hidden='true'>×</button>
<h3 id='myModalLabel'>Database Connection Installer</h3>
</div>
<div class='modal-body'>
<form action='install.php' method='post'>
<table>
<tr style='text-align: center'>
<td>Database Address: </td>
<td><input type='text' name='host' placeholder='Database Host' /></td>
</tr>
<tr style='text-align: center'>
<td>Database Username: </td>
<td><input type='text' name='username' placeholder='Database Username' /></td>
</tr>
<tr style='text-align: center'>
<td>Database Password: </td>
<td><input type='text' name='password' placeholder='Database Password' /></td>
</tr>
<tr style='text-align: center'>
<td>Database Name: </td>
<td><input type='text' name='db_name' placeholder='Database Name' /></td>
</tr>
</table>
</div>
<div class='modal-footer'>
<button class='btn btn-danger' data-dismiss='modal' aria-hidden='true'>Close</button>
<input class='btn btn-success' type='submit' name='submit' value='Connect' />
</div>
</div>";
}