I have been trying to fix a problem, but without success.
When I input data and submit in my signup form some columns in my database are not affected.
<?php
require('backend/db_con/DB_Connection.php');
$success = false;
if(isset($_POST['Register'])){
$F_name = $_POST['first_name'];
$L_name = $_POST['last_name'];
$email = $_POST['email'];
$add = $_POST['Address'];
$Country = $_POST['country'];
$City = $_POST['city'];
$Zip = $_POST['zip_code'];
$tele = $_POST['telephone'];
$password = $_POST['password'];
$confirm = $_POST['confirm'];
//validations
if($F_name=="" || $L_name=="" || $email=="" || $password=="" || $confirm=="" || $Country=="" || $City="" || $Zip="" || $add=""){
$errorMessege = "Please enter the required fields.";
}
else if(!filter_var($email, FILTER_VALIDATE_EMAIL)){
$errorMessege = "Please enter a correct email address";
}
else if($tele!="" && !is_numeric($tele)){
$errorMessege = "Please enter a correct telephone number";
}
else if($password != $confirm){
$errorMessege = "Your password and the confirmation does not match. Please try again.";
}
else if(strlen($password) <5){
$errorMessege = "Password must be atleast 6 characters";
}
if(!isset($errorMessege)){
$password = hash("sha256", $password);
$sql = "INSERT INTO clients( first_name , last_name , email , Address , country , city , zip_code , telephone , password)
VALUES('".$F_name."', '".$L_name."', '".$email."', '".$add."', '".$Country."', '".$City."', '".$Zip."', '".$tele."', '".$password."')";
mysqli_query($con, $sql);
if(mysqli_affected_rows($con) > 0){
$success = true;
}
else{
$errorMessege = "This E-mail has already registerd. Please use login page to login or try signup using a different E-mail";
}
}
}
?>
2
Answers
You declared $add and used $address on the query. Check that point.
you should check what the name of all the input filed you give does match with the $_POST[‘that input name’] and type of column in database match with the html input type