czemu wyskakuje mi ten błąd:Błąd serwera! Przepraszamy za niedogodności i prosimy o rejestrację w innym terminie!
Informacja developerska: Exception: Column count doesn't match value count at row 1 in E:\XAMPP\htdocs\antypis\signup.php:100 Stack trace: #0 {main}
mój kod:
<?php
session_start();
if (isset($_POST['email']))
{
//Udana walidacja? Załóżmy, że tak!
$wszystko_OK=true;
//Sprawdź poprawność nickname'a
$nick = $_POST['username'];
//Sprawdzenie długości nicka
if ((strlen($nick)<3) || (strlen($nick)>20))
{
$wszystko_OK=false;
$_SESSION['e_nick']="Nick musi posiadać od 3 do 20 znaków!";
}
// Sprawdź poprawność adresu email
$email = $_POST['email'];
$emailB = filter_var($email, FILTER_SANITIZE_EMAIL);
if ((filter_var($emailB, FILTER_VALIDATE_EMAIL)==false) || ($emailB!=$email))
{
$wszystko_OK=false;
$_SESSION['e_email']="Podaj poprawny adres e-mail!";
}
//Sprawdź poprawność hasła
$haslo1 = $_POST['pass1'];
$haslo2 = $_POST['pass2'];
if ((strlen($haslo1)<8) || (strlen($haslo1)>20))
{
$wszystko_OK=false;
$_SESSION['e_haslo']="Hasło musi posiadać od 8 do 20 znaków!";
}
if ($haslo1!=$haslo2)
{
$wszystko_OK=false;
$_SESSION['e_haslo']="Podane hasła nie są identyczne!";
}
$haslo_hash =md5($haslo1);
//Zapamiętaj wprowadzone dane
$_SESSION['fr_nick'] = $nick;
$_SESSION['fr_email'] = $email;
$_SESSION['fr_haslo1'] = $haslo1;
$_SESSION['fr_haslo2'] = $haslo2;
require_once "db.php";
mysqli_report(MYSQLI_REPORT_STRICT);
try
{
$polaczenie = new mysqli($db_host, $db_user, $db_pass, $db);
if ($polaczenie->connect_errno!=0)
{
throw new Exception(mysqli_connect_errno());
}
else
{
//Czy email już istnieje?
$rezultat = $polaczenie->query("SELECT id FROM `users` WHERE email='$email'");
if (!$rezultat) throw new Exception($polaczenie->error);
$ile_takich_maili = $rezultat->num_rows;
if($ile_takich_maili > 0)
{
$wszystko_OK=false;
$_SESSION['e_email']="Istnieje już konto przypisane do tego adresu e-mail!";
}
//Czy nick jest już zarezerwowany?
$rezultat = $polaczenie->query("SELECT id FROM `users` WHERE username='$nick'");
if (!$rezultat) throw new Exception($polaczenie->error);
$ile_takich_nickow = $rezultat->num_rows;
if($ile_takich_nickow > 0)
{
$wszystko_OK=false;
$_SESSION['e_nick']="Istnieje już gracz o takim nicku! Wybierz inny.";
}
if ($wszystko_OK==true)
{
//Hurra, wszystkie testy zaliczone, dodajemy gracza do bazy
$query_insert = "INSERT INTO `users` VALUES (NULL, '$nick', '$haslo_hash', '$email', 'Użytkownik')";
if ($polaczenie->query($query_insert))
{
$_SESSION['udanarejestracja']=true;
header('Location: signin.php');
}
else
{
throw new Exception($polaczenie->error);
}
}
$polaczenie->close();
}
}
catch(Exception $e)
{
echo '<span style="color:red;">Błąd serwera! Przepraszamy za niedogodności i prosimy o rejestrację w innym terminie!</span>';
echo '<br />Informacja developerska: '.$e;
}
}
?>
<html lang="pl">
<head>
<title>AntyPiS - Rejestracja</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="icon" href="logo.png">
<style>
*{
margin: 0;
padding: 0;
font-family: "Open Sans", sans-serif;
font-size: 22px;
overflow: hidden;
}
.apptile{
width: 50%;
height: 100vh;
float: left;
}
.apptile:nth-child(1){
background: url('register.jpg');
background-size: cover;
color: white;
text-align: center;
}
.apptile:nth-child(1) .row{
font-size: 40px;
display: flex;
padding: 30px;
}
.apptile:nth-child(2){
text-align: center;
}
.main-text{
font-size: 40px;
}
.pkg{
height: 88vh;
color: #fff;
font-size: 48px;
}
.pkg h1{
margin-top: 30%;
font-weight: 100;
font-size: 60px;
}
.media-login{
position: absolute;
bottom: 0;
left: 10%;
height: 10vh;
background: rgba(255,255,255, 0.5);
width: 30%;
border-radius: 40px 40px 0 0;
padding: 10px;
text-align: left;
text-align: center;
}
.media-login .facebook i{
background: #4267B2;
height: 70px;
width: 70px;
border-radius: 144px;
cursor: pointer;
line-height: 70px;
text-align: center;
transition: .9s;
}
.media-login .facebook i:hover{
height: 150px;
}
.page-form{
height: 100vh;
width: 100%;
font-size: 48px;
padding: 25px;
}
.page-form label{
font-size: 40px;
text-transform: uppercase;
color: #babfc2;
margin-bottom: 5px;
}
.page-form input{
background: white;
border:0;
border-bottom: 2px solid #141217;
outline: none;
margin-bottom: 50px;
padding: 10px 50px;
margin-top: 5px;
}
.btn-register{
padding: 10px 50px;
border: 0px;
background: #141217;
border-radius: 25px;
color: white;
font-weight: 900;
cursor: pointer;
transition: .3s;
}
.btn-register:hover{
background: #000;
}
.sectionbottom a{
color: #141217;
}
.sectionbottom{
text-align: center;
position: absolute;
bottom: 40px;
text-align: center;
}
@media only screen and (max-width: 816px) {
.sectionbottom a{
display: block;
margin-top: 5px;
}
.page-form input{
padding: 10px 0;
}
.apptile:nth-child(2){
text-align: left;
}
}
@media only screen and (max-width: 678px) {
.page-form label{
font-size: 20px;
text-transform: uppercase;
color: #babfc2;
margin-bottom: 5px;
}
.page-form input{
background: white;
border:0;
border-bottom: 2px solid #141217;
outline: none;
margin-bottom: 50px;
padding: 10px 0px;
width: 150px;
margin-top: 5px;
}
}
@media only screen and (max-width: 400px) {
.btn-register{
width: 150px;
font-size: 10px;
text-align: left;
bottom: 0;
}
.logo{display: none;}
.pkg h1, p{
font-size: 20px;
}
.apptile{
width: 100%;
height: 40vh;
float: none;
}
.media-login{
display: none;
}
.page-form label{
font-size: 20px;
text-transform: uppercase;
color: #babfc2;
margin-bottom: 5px;
}
.page-form input{
background: white;
border:0;
border-bottom: 2px solid #141217;
outline: none;
margin-bottom: 5px;
padding: 0px 0px;
width: 150px;
margin-top: 5px;
}
}
</style>
<script src="https://kit.fontawesome.com/b4c4d29cec.js" crossorigin="anonymous"></script>
</head>
<body>
<div class="apptile">
<div class="row">
<img src="logo.png" class="logo" alt="" style="height: 40px; width: 40px; border-radius: 144px;"> Anty-PiS
</div>
<div class="pkg">
<h1 class="main-text">
Jesteś gotowy dołączyć do nas?
</h1><br>
<p>
Największe polskie forum poświęcone ośmieszaniu pis'u
</p>
</div>
<div class="media-login">
<div class="facebook tile-login">
Dołącz za pomocą: <br>
<i class="fab fa-facebook-f"></i>
</div>
</div>
</div>
<div class="apptile">
<form action="" class="page-form" method="POST">
<label for="">Nazwa Użytkownika </label><br><input type="text" name="username" required><br>
<label for="">Hasło </label><br><input type="password" name="pass1" required><br>
<label for="">Potwierdź hasło </label><br><input type="password" required name="pass2"><br>
<label for="">Email </label><br><input type="email" name="email" required><br>
<?php
echo @$_SESSION['e_nick'];
echo @$_SESSION['e_email'];
echo @$_SESSION['e_haslo'];
?>
<br><br>
<div class="sectionbottom">
<button class="btn-register">Zarejestruj</button> <a href="../antypis"> Mam już konto</a>
</div>
</form>
</div>
</body>
</html>