یلدا ادامه داره... ❤️ ۴۰ درصد تخفیف همه دورهها
استفاده از تخفیفهاسلام دوستان یک مشکل در کد های php و sql جود داره !
دیتا بیس هم متصله !
ارور :
Fatal error: Uncaught mysqli_sql_exception: Column count doesn't match value count at row 1 in C:\xampp\htdocs\ucp\registration.php:23 Stack trace: #0 C:\xampp\htdocs\ucp\registration.php(23): mysqli_query(Object(mysqli), 'INSERT INTO acc...') #1 {main} thrown in C:\xampp\htdocs\ucp\registration.php on line 23
کدی که ارور توش وجود داره : (خط 2)
if($password == $confirmpassword & $username != " " & $email != " " & $password != " " & $serial != " " & $age != " " & $nationality != " "){
$query = "INSERT INTO accounts VALUES('','$username','$email','$password', '$serial', '$age', '$nationality', '100', '100', '100', 'false', '1000', '1000', 'false', '-2413.63281', '-623.00012', '132.4823')";
mysqli_query($conn, $query);
echo
"<script> window.location.pathname = ('/hr/login.php') </script>";
}
else{
echo
"<script> alert('Password Does Not Match'); </script>";
کد sql برای ساخت تیبل در دیتا بیس :
CREATE TABLE IF NOT EXISTS `accounts` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(24) NOT NULL,
`email` varchar(25) NOT NULL,
`serial` varchar(50) NOT NULL,
`birth` varchar(100) NOT NULL,
`age` varchar(100) NOT NULL,
`nationality` varchar(100) NOT NULL,
`job` varchar(100) NOT NULL,
`cash` varchar(100) NOT NULL,
`bank` varchar(100) NOT NULL,
`phone` varchar(100) NOT NULL,
`x` varchar(100) NOT NULL,
`y` varchar(100) NOT NULL,
`z` varchar(100) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
کد php در فایل config :
<?php
session_start();
$conn = mysqli_connect("localhost", "root", "", "php");
سلام دوست عزیز
کلا 14 ستون مشخص شده در جدولتون ولی شما 17 مقدار در value قرار دادید
برای id من فکر میکنم نیازی به رشته خالی نباشه تا جایی ک اطلاع دارم.
لطفا مقادیر رو مجدد بررسی کنید
کد کامل :
<?php
require 'config.php';
if(!empty($_SESSION["id"])){
header("Location: index.php");
}
if(isset($_POST["submit"])){
$username = $_POST["username"];
$email = $_POST["email"];
$password = $_POST["password"];
$serial = $_POST["serial"];
$age = $_POST["number"];
$nationality = $_POST["nationality"];
$confirmpassword = $_POST["confirmpassword"];
$duplicate = mysqli_query($conn, "SELECT * FROM accounts WHERE username = '$username' OR email = '$email' OR serial = '$serial'");
if(mysqli_num_rows($duplicate) > 0){
echo
"<script> alert('Username or Email or Serial Has Already Taken'); </script>";
}
else{
if($password == $confirmpassword & $username != " " & $email != " " & $password != " " & $serial != " " & $age != " " & $nationality != " "){
$query = "INSERT INTO accounts VALUES('','$username','$email','$password', '$serial', '$age', '$nationality', '100', '100', '100', 'false', '1000', '1000', 'false', '-2413.63281', '-623.00012', '132.4823')";
mysqli_query($conn, $query);
echo
"<script> window.location.pathname = ('/hr/login.php') </script>";
}
else{
echo
"<script> alert('Password Does Not Match'); </script>";
}
}
}
?>
<!DOCTYPE html>
<!--=== Coding by CodingLab | www.codinglabweb.com === -->
<html lang="en">
<style>
/* ===== Google Font Import - Poppins ===== */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@200;300;400;500;600&display=swap');
*{
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Poppins', sans-serif;
}
body{
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
background: #2a2185;
}
.container{
position: relative;
max-width: 1000px;
width: 100%;
border-radius: 6px;
padding: 30px;
margin: 0 15px;
background-color: #fff;
box-shadow: 0 5px 10px rgba(0,0,0,0.1);
}
.container header{
position: relative;
font-size: 20px;
font-weight: 600;
color: #333;
}
.container header::before{
content: "";
position: absolute;
left: 0;
bottom: -2px;
height: 3px;
width: 27px;
border-radius: 8px;
background-color: #2a2185;
}
.container form{
position: relative;
margin-top: 16px;
min-height: 490px;
background-color: #fff;
overflow: hidden;
}
.container form .form{
position: absolute;
background-color: #fff;
transition: 0.3s ease;
}
.container form .form.second{
opacity: 0;
pointer-events: none;
transform: translateX(100%);
}
form.secActive .form.second{
opacity: 1;
pointer-events: auto;
transform: translateX(0);
}
form.secActive .form.first{
opacity: 0;
pointer-events: none;
transform: translateX(-100%);
}
.container form .title{
display: block;
margin-bottom: 8px;
font-size: 16px;
font-weight: 500;
margin: 6px 0;
color: #333;
}
.container form .fields{
display: flex;
align-items: center;
justify-content: space-between;
flex-wrap: wrap;
}
form .fields .input-field{
display: flex;
width: calc(100% / 3 - 15px);
flex-direction: column;
margin: 4px 0;
}
.input-field label{
font-size: 12px;
font-weight: 500;
color: #2e2e2e;
}
.input-field input, select{
outline: none;
font-size: 14px;
font-weight: 400;
color: #333;
border-radius: 5px;
border: 1px solid #aaa;
padding: 0 15px;
height: 42px;
margin: 8px 0;
}
.input-field input :focus,
.input-field select:focus{
box-shadow: 0 3px 6px rgba(0,0,0,0.13);
}
.input-field select,
.input-field input[type="date"]{
color: #707070;
}
.input-field input[type="date"]:valid{
color: #333;
}
.container form button, .backBtn{
display: flex;
align-items: center;
justify-content: center;
height: 45px;
max-width: 200px;
width: 100%;
border: none;
outline: none;
color: #fff;
border-radius: 5px;
margin: 25px 0;
background-color: #2a2185;
transition: all 0.3s linear;
cursor: pointer;
}
.container form .btnText{
font-size: 14px;
font-weight: 400;
}
form button:hover{
background-color: #265df2;
}
form button i,
form .backBtn i{
margin: 0 6px;
}
form .backBtn i{
transform: rotate(180deg);
}
form .buttons{
display: flex;
align-items: center;
}
form .buttons button , .backBtn{
margin-right: 14px;
}
@media (max-width: 750px) {
.container form{
overflow-y: scroll;
}
.container form::-webkit-scrollbar{
display: none;
}
form .fields .input-field{
width: calc(100% / 2 - 15px);
}
}
@media (max-width: 550px) {
form .fields .input-field{
width: 100%;
}
}
</style>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!----======== CSS ======== -->
<!----===== Iconscout CSS ===== -->
<link rel="stylesheet" href="https://unicons.iconscout.com/release/v4.0.0/css/line.css">
<title>HypixelRP | Register</title>
</head>
<body>
<div class="container">
<header>Registration</header>
<form action="#" method="post" autocomplete="off">
<div class="form first">
<div class="details personal">
<span class="title">Personal Details</span>
<div class="fields">
<div class="input-field">
<label>Username</label>
<input type="text" id="username" name="username" required placeholder="Insert your username"><!--name--->
</div>
<div class="input-field">
<label id="email">Email</label>
<input type="email" id="email" name="email" required placeholder="Insert your email">
</div>
<div class="input-field">
<label id="password">Password</label>
<input type="password" id="password" name="password" required placeholder="Insert your password">
</div>
<div class="input-field">
<label id="confirmpassword">Confirm Password</label>
<input type="password" id="confirmpassword" name="confirmpassword" required placeholder="Insert your password"><!---password-->
</div>
<div class="input-field">
<label id="serial">Serial</label>
<input type="text" id="serial" name="serial" required placeholder="Insert your serial"><!---serial-->
</div>
<div class="input-field">
<label id="number">Age</label>
<input type="number" id="number" name="number" placeholder="Age" min=18 max=60 required><!---number-->
</div>
<div class="input-field">
<label id="nationality">Nationality</label>
<input type="text" id="nationality" name="nationality" required placeholder="Insert your nationality"><!---nationality-->
</div>
<div class="input-field">
<label id="discordn">Discord Name</label>
<input type="text" id="discordn" name="discordn" required placeholder="Insert your discord name"><!---nationality-->
</div>
<div class="input-field">
<label>Date of Birth</label>
<input type="date" placeholder="Enter birth date" required>
</div>
</div>
</div>
<button class="sumbit" type="submit" name="submit">
<span class="btnText">Submit</span>
<i class="uil uil-navigator"></i>
</button>
<a class="color_text" href="login.php"> <=Login</a>
</div>
</form>
</div>
<script>
const form = document.querySelector("form"),
nextBtn = form.querySelector(".nextBtn"),
backBtn = form.querySelector(".backBtn"),
allInput = form.querySelectorAll(".first input");
nextBtn.addEventListener("click", ()=> {
allInput.forEach(input => {
if(input.value != ""){
form.classList.add('secActive');
}else{
form.classList.remove('secActive');
}
})
})
backBtn.addEventListener("click", () => form.classList.remove('secActive'));
</script>
</body>
</html>
سلام دوست عزیز
کلا 14 ستون مشخص شده در جدولتون ولی شما 17 مقدار در value قرار دادید
برای id من فکر میکنم نیازی به رشته خالی نباشه تا جایی ک اطلاع دارم.
لطفا مقادیر رو مجدد بررسی کنید
به متن خطا خیلی دقت کنید همیشه بهترین راهنما هست
Column count doesn't match value count at row 1
خودش میگه تعدادستون و مقادیر با هم همخونی نداره
آیا مایل به ارسال نوتیفیکیشن و اخبار از طرف راکت هستید ؟