php - Is this code protected against SQL injection? -


i'm not familiar newer php commands, wanted check if code below protected against sql injection?

$mysqli = new mysqli($server,$user , $password, $db_name); $stmt1 = $mysqli->prepare("insert $db_table (request_date, from_city, from_country, to_city, to_country, travel_date, return_date, minus, plus, currency)                                          values(?,?,?,?,?,?,?,?,?,?)");  $date = date('y-m-d h:i:s'); $stmt1->bind_param("ssssssssss",$date,                                 $_post['from_city'],                                  $_post['from_country'],                                  $_post['to_city'],                                  $_post['to_country'],                                  $_post['travel_date'],                                  $_post['return_date'],                                  $_post['minus'],                                  $_post['plus'],                                  $_post['currency']                     );  $stmt1->execute(); 

basically, script receives post data form, records them db, , submits them script perform actual search (on third-party website).

yes, prepared statements safe against sql injection not interpreted part of sql query - can have there, won't execute command.

that said, may want bit of validation anyway make sure data accepting makes sense. garbage in, garbage out. don't want save date that's not valid, instance.


Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -