This article describes the example of php using mysqli to add data to the database. Share it with everyone for your reference. The specific implementation method is as follows:
$mydb = new mysqli('localhost', 'username', 'password', 'databasename'); $sql = "INSERT INTO users (fname, lname, comments) VALUES ('$_POST[fname]', '$_POST[lname]', '$_POST[comments]')"; if ($mydb->query($sql) == TRUE) { echo "user entry saved successfully."; } else { echo "INSERT attempt failed" ; } $mydb->close();
I hope this article will be helpful to everyone’s PHP programming design.