nag eerror po tapos ayaw ma submit sa database :<
Fatal error: Uncaught ArgumentCountError: The number of elements in the type definition string must match the number of bind variables in D:\xampp\htdocs\FINAL\register.php:64 Stack trace: #0 D:\xampp\htdocs\FINAL\register.php(64): mysqli_stmt_bind_param(Object(mysqli_stmt), 'ss', NULL, NULL, NULL, 'SXOPEMAPIA', NULL) #1 {main} thrown in D:\xampp\htdocs\FINAL\register.php on line 64
ito yung code ko
Fatal error: Uncaught ArgumentCountError: The number of elements in the type definition string must match the number of bind variables in D:\xampp\htdocs\FINAL\register.php:64 Stack trace: #0 D:\xampp\htdocs\FINAL\register.php(64): mysqli_stmt_bind_param(Object(mysqli_stmt), 'ss', NULL, NULL, NULL, 'SXOPEMAPIA', NULL) #1 {main} thrown in D:\xampp\htdocs\FINAL\register.php on line 64
ito yung code ko
Code:
<?php
require_once "db.php";
$email = $fname = $lname = $username = $password = $confirm_password = "";
$email_err = $fname_err = $lname_err = $username_err = $password_err = $confirm_password_err = "";
if($_SERVER["REQUEST_METHOD"] == "POST"){
if(empty(trim($_POST["email"]))){
$email_err = "Please enter a Email.";
}
if(empty(trim($_POST["fname"]))){
$fname_err = "Please enter a First Name.";
}
if(empty(trim($_POST["lname"]))){
$lname_err = "Please enter a Last Name.";
}
if(empty(trim($_POST["username"]))){
$username_err = "Please enter a Username.";
} else{
$sql = "SELECT id FROM users WHERE email = ?";
$sql = "SELECT id FROM users WHERE fname = ?";
$sql = "SELECT id FROM users WHERE lname = ?";
$sql = "SELECT id FROM users WHERE username = ?";
if($stmt = mysqli_prepare($link, $sql)){
mysqli_stmt_bind_param($stmt, "s", $param_email);
mysqli_stmt_bind_param($stmt, "s", $param_fname);
mysqli_stmt_bind_param($stmt, "s", $param_lname);
mysqli_stmt_bind_param($stmt, "s", $param_username);
$param_username = trim($_POST["email"]);
$param_username = trim($_POST["fname"]);
$param_username = trim($_POST["lname"]);
$param_username = trim($_POST["username"]);
if(mysqli_stmt_execute($stmt)){
mysqli_stmt_store_result($stmt);
if(mysqli_stmt_num_rows($stmt) == 1){
$username_err = "This username is already taken.";
} else{
$username = trim($_POST["username"]);
}
} else{
echo "Oops! Something went wrong. Please try again later.";
}
mysqli_stmt_close($stmt);
}
}
if(empty(trim($_POST["password"]))){
$password_err = "Please enter a password.";
} elseif(strlen(trim($_POST["password"])) < 6){
$password_err = "Password must have atleast 6 characters.";
} else{
$password = trim($_POST["password"]);
}
if(empty(trim($_POST["confirm_password"]))){
$confirm_password_err = "Please confirm password.";
} else{
$confirm_password = trim($_POST["confirm_password"]);
if(empty($password_err) && ($password != $confirm_password)){
$confirm_password_err = "Password did not match.";
}
}
if(empty($email_err) && empty($fname_err) && empty($lname_err) &&empty($username_err) && empty($password_err) && empty($confirm_password_err)){
$sql = "INSERT INTO users (email, fname, lname, username, password) VALUES (?, ?, ?, ?, ?)";
if($stmt = mysqli_prepare($link, $sql)){
mysqli_stmt_bind_param($stmt, "ss", $param_email, $param_fname, $param_lname, $param_username, $param_password);
$param_email = $email;
$param_fname = $fname;
$param_lname = $lname;
$param_username = $username;
$param_password = password_hash($password, PASSWORD_DEFAULT);
if(mysqli_stmt_execute($stmt)){
header("location: index.php");
} else{
echo "Oops! Something went wrong. Please try again later.";
}
mysqli_stmt_close($stmt);
}
}
mysqli_close($link);
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Login and registration form</title>
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400" rel="stylesheet" />
<link href="style.css" rel="stylesheet" />
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400&display=swap" rel="stylesheet">
<link rel="stylesheet" href="owl.carousel.min.css">
<link rel="stylesheet" href="bootstrap.min.css">
<script src="https://kit.fontawesome.com/a076d05399.js" crossorigin="anonymous"></script>
</head>
<body>
<div class="container">
<!-- Top box -->
<!-- Logo & Site Name -->
<div class="placeholder">
<div class="parallax-window" data-parallax="scroll" data-image-src="images/cover/cover.jpg">
<div class="header">
<div class="row header-inner">
<div class="col-md-6 col-12">
<img src="images/cover/Thrasher.jpg" class="logo" />
</div>
<nav class="col-md-6 col-12 nav">
<ul class="nav-ul">
<li class="nav-li"><a href="Website.php" class="nav-link active">Home</a></li>
<li class="nav-li"><a href="#" class="nav-link">About</a></li>
<li class="nav-li"><a href="#" class="nav-link">Contact</a></li>
</ul>
</nav>
</div>
</div>
</div>
</div>
<main>
<header class="welcome-section">
<h2 class="col-12 section-title">WELCOME TO THRASHER MAGAZINE</h2>
<p class="col-12">Thrasher is a skateboarding magazine founded in January 1981 by Eric Swenson and Fausto Vitello. The publication consists primarily of skateboard and music-related articles, photography, interviews and skatepark reviews..</p>
</header>
<h1 class="section-title">SIGN-UP HERE!</h1>
<?php
if(!empty($login_err)){
echo '<div class="alert">' . $login_err . '</div>';
}
?>
<p class="mb-4">Please fill in your credentials to login.</p>
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" method="post">
<div class="InputF">
<label>Email</label>
<input type="text" name="email" class="form-control <?php echo (!empty($email_err)) ? 'is-invalid' : ''; ?>" value="<?php echo $email; ?>"> <br>
<span class="invalid-feedback"><?php echo $email_err; ?></span>
</div>
<div class="InputF">
<label>First Name</label>
<input type="text" name="fname" class="form-control <?php echo (!empty($fname_err)) ? 'is-invalid' : ''; ?>" value="<?php echo $fname; ?>"> <br>
<span class="invalid-feedback"><?php echo $fname_err; ?></span>
</div>
<div class="InputF">
<label>Last Name</label>
<input type="text" name="lname" class="form-control <?php echo (!empty($lname_err)) ? 'is-invalid' : ''; ?>" value="<?php echo $lname; ?>"> <br>
<span class="invalid-feedback"><?php echo $lname_err; ?></span>
</div>
<div class="InputF">
<label>Username</label>
<input type="text" name="username" class="form-control <?php echo (!empty($username_err)) ? 'is-invalid' : ''; ?>" value="<?php echo $username; ?>"> <br>
<span class="invalid-feedback"><?php echo $username_err; ?></span>
</div>
<div class="InputF">
<label>Password</label>
<input type="password" name="password" class="form-control> <?php echo (!empty($password_err)) ? 'is-invalid' : ''; ?>" value="<?php echo $password; ?>"> <br>
<span class="invalid-feedback"><?php echo $password_err; ?></span>
</div>
<div class="InputF">
<label>Confirm Password</label>
<input type="password" name="confirm_password" class="form-control <?php echo (!empty($confirm_password_err)) ? 'is-invalid' : ''; ?>" value="<?php echo $confirm_password; ?>"> <br>
<span class="invalid-feedback"><?php echo $confirm_password_err; ?></span>
</div>
<div class="form-group">
<input type="submit" class="btn btn-primary" value="Submit">
<input type="reset" class="btn btn-secondary ml-2" value="Reset">
</div>
<p>Don't have an account? <a href="index.php" >Login</a>.</p>
<span class="d-block text-center my-4 text-muted"><p>— or —</p></span>
<div class="social-login">
<a href="#" class="facebook btn d-flex justify-content-center align-items-center">
<span class="fab fa-facebook-f"></span> Signup with Facebook
</a>
<a href="#" class="twitter btn d-flex justify-content-center align-items-center">
<span class="fab fa-twitter"></span> Sign up with Twitter
</a>
<a href="#" class="google btn d-flex justify-content-center align-items-center">
<span class="fab fa-google"></span> Sign up with Google
</a>
</a>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</figure>
</article>
</div>
</main>
</div>
<script src="js/jquery.min.js"></script>
<script src="js/parallax.min.js"></script>
<script>
$(document).ready(function(){
// Handle click on paging links
$('.paging-link').click(function(e){
e.preventDefault();
var page = $(this).text().toLowerCase();
$('.gallery-page').addClass('hidden');
$('#gallery-page-' + page).removeClass('hidden');
$('.paging-link').removeClass('active');
$(this).addClass("active");
});
});
</script>
</body>
</html>
Last edited: