For learning purposes
This code:
<?php
if (isset($_POST['submit'])) {
# code...
$code = $_POST['code'];
$cname = $_POST['cname'];
$address = $_POST['address'];
$email = $_POST['email'];
$contact = $_POST['contact'];
$newCustomer = mysqli_query($con,"INSERT INTO `tbl_customer`(`code`, `name`, `address`, `cemail`, `ccontact`) VALUES ('$code','$cname','$address','$email','$contact')") or die(
'<div class="alert alert-warning">
<strong>Error!</strong> Code is already in use.
</div>'
);
echo '<div class="alert alert-success">
<strong>Success!</strong> You inserted a new Customer.
</div>';
}
?>
is subject to sql injection. I am still learning so can you help me with how to prepare this statement to avoid sql injection? I need some implantation examples that are specific to this use case. please don't refer me to another post.