I have this register form that I like all my data to be sent to my mysql server using php. Here's my code:
$gidnumber = htmlentities($_POST['stud_idnumber']);
$gfirstname = htmlentities($_POST['stud_firstname']);
$glastname = htmlentities($_POST['stud_lastname']);
$gcourse = htmlentities($_POST['stud_course']);
$gyear = htmlentities($_POST['stud_year']);
$gpassword = htmlentities($_POST['stud_password']);
For security reasons, I tried doubling up by using real_escape_string
$stud_idnumber = mysqli_real_escape_string($con,$gidnumber);
$stud_firstname = mysqli_real_escape_string($con,$gfirstname);
$stud_lastname = mysqli_real_escape_string($con,$glastname);
$stud_course = mysqli_real_escape_string($con,$gcourse);
$stud_year = mysqli_real_escape_string($con,$gyear);
$stud_password = mysqli_real_escape_string($con,$gpassword);
Followed by a:
$sql3 = "INSERT INTO users_student
(idnumber, firstname, lastname, course, year, password)
VALUES "." ('$stud_idnumber','$stud_firstname','$stud_lastname',
'$stud_course','$stud_year','$stud_password') ";
$q = mysqli_query($con,$sql3);
echo "<br/><br/><br/><br/><br/><br/><br/>";
echo $stud_idnumber;
echo $stud_firstname;
echo $stud_lastname;
echo $stud_course;
echo $stud_year;
echo $stud_password;
The echo
part was for checking if the php really gets all the variables in the textboxes. On my page, it successfully displayed all the user has input in the textbox (firstname, lastname, etc...). But when I checked my database, it didn't saved it there.
Also it was not giving me any errors.