T werkt al, alleen als ik een query toevoeg, en die met een POST activeer, wordt heel het beeld wit...
if (isset($_POST['login'])) {
$prefix = $mysqli->real_escape_string($_CONFIG['prefix']);
$table = $prefix.'users';
$adminuser = $mysqli->real_escape_string($_CONFIG['adminuser']);
$adminpass = $mysqli->real_escape_string(password_hash($_CONFIG['adminpass'], PASSWORD_DEFAULT));
$adminemail = $mysqli->real_escape_string($_CONFIG['adminemail']);
$sql = "INSERT INTO `$table` (`username`, `password`, `email`) VALUES ('$adminuser', '$adminpass', '$adminemail')";
if ($mysqli->query($sql) === TRUE) {
header('Location: /');
exit();
} else {
echo "Error: " . $sql . "<br>" . $mysqli->error;
}
header('Location: /');
exit();
}
de voledige code:
[code]
<?php
error_reporting(0);
session_start();
$_CONFIG = parse_ini_file($_SERVER["DOCUMENT_ROOT"] . '/../datafile.ini');
if ($_CONFIG['installation'] == 1) {
header('Location: /');
exit();
}
if ($_CONFIG['configuration'] == 0) {
header('Location: /configuration');
exit();
}
if (empty($_GET['stap'])) {
if ($_CONFIG['language'] == "nl") {
$content = '
<body class="wp-core-ui">
<h1>Welkom</h1>
<p>Welkom bij de vijf minuten installatieproces van het paneel. Vul gewoon de informatie hieronder in en u bent klaar om nieuwste community paneel te gebruiken.</p>
<h2>Benodigde informatie</h2>
<p>De volgende informatie invoeren. Geen zorgen, deze gegevens kunnen in een later stadium worden gewijzigd.</p>
<form id="setup" method="post" novalidate="novalidate">
<table class="form-table">
<tbody><tr>
<th scope="row"><label for="company">Bedrijfsnaam</label></th>
<td><input name="company" type="text" id="company" size="25" value="" required></td>
</tr>
<tr>
<th scope="row"><label for="adminuser">Gebruikersnaam</label></th>
<td>
<input name="adminuser" type="text" id="adminuser" size="25" value="">
<p>Gebruikersnamen mogen alleen alfanumerieke karakters, spaties, underscores, koppeltekens, punten en het @ symbool bevatten.</p>
</td>
</tr>
<tr class="form-field form-required user-pass1-wrap">
<th scope="row">
<label for="adminpass">
Wachtwoord </label>
</th>
<td>
<div class="password">
<input type="text" name="adminpass" id="adminpass" autocomplete="off" data-reveal="1" value="XlX6WZB@Fg7pe!JV47" required>
</div>
<p><span class="description important">
<strong>Belangrijk:</strong>
Dit wachtwoord is nodig om in te loggen. Zorg ervoor dat u het bewaard op een geheime locatie.</span></p>
</td>
</tr>
<tr>
<th scope="row"><label for="adminemail">Uw e-mailadres</label></th>
<td><input name="adminemail" type="adminemail" id="adminemail" size="25" value="" required>
<p>Controleer uw e-mailadres voordat u verder gaat.</p></td>
</tr>
<tr>
<tr>
<th scope="row"><label for="companylogo">Bedrijfslogo</label></th>
<td><input name="companylogo" type="text" id="companylogo" size="25" value="" required>
<p>Zorg voor een werkende link die transparant is.</p></td>
</tr>
</tr>
</tbody></table>
<p class="step"><input type="submit" name="Submit" id="submit" class="button button-large" value="Het paneel installeren"></p>
</form>
</body>
';
} else {
$content = '
<body class="wp-core-ui">
<h1>Welcome</h1>
<p>Welcome by the five minutes installationpreces for the panel. Just full in the information below and you are ready to use the neweest community panel.</p>
<h2>Needed information</h2>
<p>Full in the next information. Don'."''".'t worry, those details can be changed in another stadium.</p>
<form id="setup" method="post" novalidate="novalidate">
<table class="form-table">
<tbody><tr>
<th scope="row"><label for="company">Company name</label></th>
<td><input name="company" type="text" id="company" size="25" value="" required></td>
</tr>
<tr>
<th scope="row"><label for="adminuser">Username</label></th>
<td>
<input name="adminuser" type="text" id="adminuser" size="25" value="">
<p>
Usernames can only contain alphanumeric characters, spaces, underscores, hyphens, periods and the @ symbol.</p>
</td>
</tr>
<tr class="form-field form-required user-pass1-wrap">
<th scope="row">
<label for="adminpass">
Password </label>
</th>
<td>
<div class="password">
<input type="text" name="adminpass" id="adminpass" autocomplete="off" data-reveal="1" value="XlX6WZB@Fg7pe!JV47" required>
</div>
<p><span class="description important">
<strong>Important:</strong>
This password is required to log in. Make sure you are safe it in a secret location.</span></p>
</td>
</tr>
<tr>
<th scope="row"><label for="adminemail">Your email</label></th>
<td><input name="adminemail" type="adminemail" id="adminemail" size="25" value="" required>
<p>
Check your email before continuing.</p></td>
</tr>
<tr>
<tr>
<th scope="row"><label for="companylogo">Company logo</label></th>
<td><input name="companylogo" type="text" id="companylogo" size="25" value="" required>
<p>
Provide a working link that is transparent.</p></td>
</tr>
</tr>
</tbody></table>
<p class="step"><input type="submit" name="Submit" id="submit" class="button button-large" value="Install the panel"></p>
</form>
</body>
';
}
} elseif ($_GET['stap'] == 1) {
if ($_CONFIG['language'] == "nl") {
$content = '
<body class="wp-core-ui">
<h1>Gelukt!</h1>
<p>Het paneel is geïnstalleerd. Had je meer stappen verwacht? Sorry voor u teleur te stellen.</p>
<form method="post">
<table class="form-table">
<tbody>
<tr>
<th scope="row"><label for="user">Gebruikersnaam</label></th>
<td>'.$_CONFIG["adminuser"].'</td>
</tr>
<tr>
<th scope="row"><label for="user">Wachtwoord</label></th>
<td><i>Je gekozen wachtwoord.</i></td>
</tr>
</tbody>
</table>
<input type="hidden" name="installation" value="1">
<p class="step"><input type="submit" name="login" id="submit" class="button button-large" value="Inloggen"></p>
</form>
</body>
';
} else {
$content = '
<body class="wp-core-ui">
<h1>Succes!</h1>
<p>The panel has been installed. Were you expecting more steps? Sorry to dissapoint you.</p>
<form method="post">
<table class="form-table">
<tbody>
<tr>
<th scope="row"><label for="user">Username</label></th>
<td>'.$_CONFIG["adminuser"].'</td>
</tr>
<tr>
<th scope="row"><label for="user">Password</label></th>
<td><i>Your chosen password.</i></td>
</tr>
</tbody>
</table>
<input type="hidden" name="installation" value="1">
<p class="step"><input type="submit" name="login" id="submit" class="button button-large" value="Log in"></p>
</form>
</body>
';
}
}
if (isset($_POST['language'])) {
header('Location: ?stap=1');
}
if (empty($_POST['language'])) {
$_POST['language'] = $_CONFIG['language'];
}
if (empty($_POST['hostname'])) {
$_POST['hostname'] = $_CONFIG['hostname'];
}
if (empty($_POST['user'])) {
$_POST['user'] = $_CONFIG['username'];
}
if (empty($_POST['pass'])) {
$_POST['pass'] = $_CONFIG['password'];
}
if (empty($_POST['database'])) {
$_POST['database'] = $_CONFIG['database'];
}
if (empty($_POST['prefix'])) {
$_POST['prefix'] = $_CONFIG['prefix'];
}
if (empty($_POST['configuration'])) {
$_POST['configuration'] = $_CONFIG['configuration'];
}
if (empty($_POST['company'])) {
$_POST['company'] = $_CONFIG['company'];
}
if (empty($_POST['companylogo'])) {
$_POST['companylogo'] = $_CONFIG['companylogo'];
}
if (empty($_POST['adminuser'])) {
$_POST['adminuser'] = $_CONFIG['adminuser'];
}
if (empty($_POST['adminpass'])) {
$_POST['adminpass'] = $_CONFIG['adminpass'];
}
if (empty($_POST['adminemail'])) {
$_POST['adminemail'] = $_CONFIG['adminemail'];
}
if (empty($_POST['installation'])) {
$_POST['installation'] = $_CONFIG['installation'];
}
$array = array(
'language' => $_POST['language'],
'hostname' => $_POST['hostname'],
'username' => $_POST['user'],
'password' => $_POST['pass'],
'database' => $_POST['database'],
'prefix' => $_POST['prefix'],
'company' => $_POST['company'],
'companylogo' => $_POST['companylogo'],
'adminuser' => $_POST['adminuser'],
'adminpass' => $_POST['adminpass'],
'adminemail' => $_POST['adminemail'],
'configuration' => $_POST['configuration'],
'installation' => $_POST['installation'],
'encoding' => 'ANSI'
);
write_php_ini($array, $_SERVER["DOCUMENT_ROOT"] . "/../datafile.ini");
/*DO NOT EDIT UNDER THIS LINE! */
/* ==============================================================*/
function write_php_ini($array, $file)
{
$res = array();
foreach($array as $key => $val)
{
if(is_array($val))
{
$res[] = "[$key]";
foreach($val as $skey => $sval) $res[] = "$skey = ".(is_numeric($sval) ? $sval : '"'.$sval.'"');
}
else $res[] = "$key = ".(is_numeric($val) ? $val : '"'.$val.'"');
}
safefilerewrite($file, implode("\r\n", $res));
}
function safefilerewrite($fileName, $dataToSave)
{ if ($fp = fopen($fileName, 'w'))
{
$startTime = microtime(TRUE);
do
{ $canWrite = flock($fp, LOCK_EX);
// If lock not obtained sleep for 0 - 100 milliseconds, to avoid collision and CPU load
if(!$canWrite) usleep(round(rand(0, 100)*1000));
} while ((!$canWrite)and((microtime(TRUE)-$startTime) < 5));
//file was locked so now we can store information
if ($canWrite)
{ fwrite($fp, $dataToSave);
flock($fp, LOCK_UN);
}
fclose($fp);
header('?stap=');
}
}
if (isset($_POST['login'])) {
$prefix = $mysqli->real_escape_string($_CONFIG['prefix']);
$table = $prefix.'users';
$adminuser = $mysqli->real_escape_string($_CONFIG['adminuser']);
$adminpass = $mysqli->real_escape_string(password_hash($_CONFIG['adminpass'], PASSWORD_DEFAULT));
$adminemail = $mysqli->real_escape_string($_CONFIG['adminemail']);
$sql = "INSERT INTO `$table` (`username`, `password`, `email`) VALUES ('$adminuser', '$adminpass', '$adminemail')";
if ($mysqli->query($sql) === TRUE) {
header('Location: /');
exit();
} else {
echo "Error: " . $sql . "<br>" . $mysqli->error;
}
header('Location: /');
exit();
}
if (isset($_POST['Submit'])) {
header('Location: ?stap=1');
}
?>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Paneel - <?php if ($_CONFIG['language'] == "nl") { echo 'Installatie';} else { echo 'Installation';} ?></title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel='stylesheet' id='buttons-css' href='paneel/assets/css/installation.button.css' type='text/css' media='all'>
<link rel='stylesheet' id='install-css' href='paneel/assets/css/installation.css' type='text/css' media='all'>
</head>
<?php
echo $content;
?>
</html>
[code]
bij fclose($fp); daaronder heb ik header('?stap='); gezet anders werd het ook wit scherm..?