I am new to PHP and i just tried to create a Sign-up login form, here is my register.html file when i login i am getting an error called "empty fields"
<!doctype html><html lang="en"><head><title>Login 03</title><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=Lato:300,400,700&display=swap" rel="stylesheet"><link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"><link rel="stylesheet" href="css/style.css"></head><body><section class="ftco-section"><div class="container"><div class="row justify-content-center"><div class="col-md-6 text-center mb-5"><h2 class="heading-section">Register</h2></div></div><div class="row justify-content-center"><div class="col-md-7 col-lg-5"><div class="login-wrap p-4 p-md-5"><div class="d-flex"><div class="w-100"><h3 class="mb-4">Sign Up</h3></div><div class="w-100"><p class="social-media d-flex justify-content-end"><a href="#" class="social-icon d-flex align-items-center justify-content-center"><span class="fa fa-facebook"></span></a><a href="#" class="social-icon d-flex align-items-center justify-content-center"><span class="fa fa-twitter"></span></a></p></div></div><form action="register.php" method="post" class="login-form"><div class="form-group"><div class="icon d-flex align-items-center justify-content-center"><span class="fa fa-user"></span></div><lable for="fname"></lable><input type="text" class="form-control rounded-left" placeholder="First Name" required></div><div class="form-group"><div class="icon d-flex align-items-center justify-content-center"><span class="fa fa-user"></span></div><lable for="lname"></lable><input type="text" class="form-control rounded-left" placeholder="Last Name" required></div><div class="form-group"><div class="icon d-flex align-items-center justify-content-center"><span class="fa fa-envelope"></span></div><lable for="email"></lable><input type="text" class="form-control rounded-left" placeholder="Email" required></div><div class="form-group"><div class="icon d-flex align-items-center justify-content-center"><span class="fa fa-phone"></span></div><lable for="phone"></lable><input type="text" class="form-control rounded-left" placeholder="Phone Number" required></div><div class="form-group"><div class="icon d-flex align-items-center justify-content-center"><span class="fa fa-lock"></span></div><lable for="password"></lable><input type="password" class="form-control rounded-left" placeholder="Password" required></div><div class="form-group d-flex align-items-center"><div class="w-100"><label class="checkbox-wrap checkbox-primary mb-0">Save Password<input type="checkbox" checked><span class="checkmark"></span></label></div><div class="w-100 d-flex justify-content-end"><button type="submit" class="btn btn-primary rounded submit">Register</button></div></div><div class="form-group mt-4"><div class="w-100 text-center"><p class="mb-1">Already have an account? <a href="#">login</a></p><p><a href="#">Forgot Password?</a></p></div></div></form></div></div></div></div></section><script src="js/jquery.min.js"></script><script src="js/popper.js"></script><script src="js/bootstrap.min.js"></script><script src="js/main.js"></script></body></html>
and here is my register.php file when i wrote the coding part for register.html
<?php require 'config.php'; if(!isset($_POST['fname'], $_POST['lname'], $_POST['email'], $_POST['phone'], $_POST['password'])){ exit('empty fields'); } if(empty($_POST['fname'] || empty($_POST['lname']) || empty($_POST['email']) || empty($_POST['phone']) || empty($_POST['password']))) { exit('values empty'); } if($stmt = $conn->prepare('SELECT id, password FROM users WHERE email = ?')){ $stmt->bind_param('s', $_POST['email']); $stmt->execute(); $stmt->store_result(); if($stmt->num_rows>0){ echo 'username already exists'; } else{ if($stmt = $con->prepare('INSERT INTO users (fname, lname, email, phone, password) VALUES (?, ?, ?, ?, ?)')){ $password = password_hash($_POST['password'], PASSWORD_DEFAULT); $stmt->bind_param('sss', $_POST['fname'], $password, $POST['lname'], $POST['email'], $POST['phone']); $stmt->execute(); echo 'sucessfully registred'; } else { echo 'error occured'; } } $stmt->close(); } else{ echo 'error occured'; } $con->close(); ?>
I have attached the screenshot of the error below
I have attached the screenshot of the error below
I was trying to create a simple login and register page and then i got the error