how do I concat two columns? I need it to have FIRSTNAME AND LASTNAME to equal $Employee_Name I tried different combinations and still doesn't work. Also I know this has a huge SQL injection issue. I do not know yet how to correct the issue I am looking it up.
<?php
header('Content-Type: application/json');$db_conx = mysqli_connect("localhost", "root", "systems399","employees_db");
$Employee_Name= $_POST["Employee_Name"];
$sql="SELECT * FROM names WHERE FIRSTNAME='$Employee_Name' ";
$query= mysqli_query($db_conx, $sql);
$row = mysqli_fetch_array($query, MYSQLI_ASSOC);
$rc= $row["EMPLOYEE_NUMBER"];
echo json_encode ($rc);
?>
I tried it this way and it doesn't work.
<?php
header('Content-Type: application/json');
$db_conx = mysqli_connect("localhost", "root", "systems399", "employees_db");
$Employee_Name= $_POST["Employee_Name"];
$sql="SELECT * FROM names WHERE FIRSTNAME='$Employee_Name' AND LASTNAME='$Employee_Name'";
$query= mysqli_query($db_conx, $sql);
$row = mysqli_fetch_array($query, MYSQLI_ASSOC);
$rc= $row["EMPLOYEE_NUMBER"];
echo json_encode ($rc);
?>
Here is my Javascript code
$(document).ready(function() {
$("#Employee_Name").change(function() {
var Employee_Name = $(this).val();
if (Employee_Name != '') {
$.ajax({
type: "post",
url: "insert.php",
data: "Employee_Name=" + Employee_Name,
datatype: "json",
success: function(data) {
$("#Employee_Number").val(data);
$('#Employee_Number').css("background-color", "#B3CBD6")
$('#Employee_Number').animate({
backgroundColor: "#ffffff"
});
},
error: function(response) {
alert("error scripting")
}
});
} else {
$("#Employee_Number").val("");
}
});
});