I'm new here to ask a question. Sorry if my question had miss explanation. I just wanna ask if my PHP
code is secure enough. Please find below is the source code:
Get the ID for choosing the Value
/*Create a new Query for get all the ID from each of Venue Type on the Administration Database*/
$Q_VenueType = "SELECT Biz_ID FROM Biz";
$R_VenueType = $connection->query($Q_VenueType);
if ($R_VenueType->num_rows > 0) {
//Success Condition
$rows = array();
while ($row = $R_VenueType->fetch_assoc()) {
$rows[] = $row;
}
echo json_encode($rows);
$R_VenueType->close();
}else{
//Failed Condition
echo('0');
}
mysqli_close($connection);
Get Value with the ID as an Input
//Create Variable to get the Venue Type Value by their ID.
$VenueType_ID = htmlspecialchars($_POST['TypeID'], ENT_QUOTES);
/*Create a new Query for get all the ID from each of Venue Type on the Administration Database*/
$Q_VenueTypeValue = "SELECT Biz_Name FROM Biz WHERE Biz_ID = '".$VenueType_ID."'";
$R_VenueTypeValue = $connection->query($Q_VenueTypeValue);
if ($R_VenueTypeValue->num_rows > 0) {
//Success Condition
$rows = array();
while ($row = $R_VenueTypeValue->fetch_assoc()) {
$rows[] = $row;
}
echo json_encode($rows);
}else{
//Failed Condition
echo('0');
}
mysqli_close($connection);
Question:
1.) Is my input for handling the user input already in the safe condition on this age? (
$VenueType_ID = htmlspecialchars($_POST['TypeID'], ENT_QUOTES);
)2.) Is my query for processing into my database already in the safe condition on this age? (
$Q_VenueTypeValue = "SELECT Biz_Name FROM Biz WHERE Biz_ID = '".$VenueType_ID."'";
and$Q_VenueType = "SELECT Biz_ID FROM Biz";
)3.) Is my fetching data code already in the safe condition on this age? (
if ($R_VenueTypeValue->num_rows > 0) {
//Success Condition
$rows = array();
while ($row = $R_VenueTypeValue->fetch_assoc()) {
$rows[] = $row;
}
echo json_encode($rows);
}else{
//Failed Condition
echo('0');
}
mysqli_close($connection);
)
If there is not safe code or condition with all the codes kindly tell me how is it to be safe? What I need to add or change?
Pardon for my English guys :). Please ask for further information, Thank you for the answer before.