The following is a snippet of my code
if(isset($_POST['register'])){
include("../includes/config.php");
$otp = $_POST['otp'];
$sentotp = $_SESSION['otp'];
if(empty($_POST['otp'])){
$error= '<b>OTP cannot be empty.</b>';
}
if($otp==$sentotp){
$fname=$_SESSION['fname'];
$lname=$_SESSION['lname'];
$email=$_SESSION['email'];
$pwd=$_SESSION['password'];
$phno=$_SESSION['phno'];
$result2=mysqli_query($db,"INSERT INTO `user`(`fname`, `lname`,`password`, `phno`,`email`) VALUES ($fname,$lname,$pwd,$phno,$email);");
unset($_SESSION['fname']);
unset($_SESSION['lname']);
unset($_SESSION['email']);
unset($_SESSION['password']);
unset($_SESSION['phno']);
//header('Location: ../src/index.php');
}
}
As we can see, fname,lname,password and email are string datatype. But for some reason the email is not getting inserted into my db. I have tried debugging by using the following query
$result2=mysqli_query($db,"INSERT INTO `user`(`fname`, `lname`,`password`, `phno`) VALUES ($fname,$lname,$pwd,$phno);");
In this case, the query is getting executed. Before someone suggests that $_SESSION['email'] might be NULL, I would like to clarify that it's not. I have echoed the $_SESSION['email'] and it is returning a perfect string. Also, I have set the the length of the email field to 100, so length of the email should also be not an issue.