This article mainly introduces the method of PHP using mysqli to add data to the database. An example analysis of how PHP uses mysqli to perform database operations. Skills, very practical value, friends in need can refer to it
The example in this article describes how PHP uses mysqli to add data to the database. Share it with everyone for your reference. The specific implementation method is as follows:
?
3 4 5
|
$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) { |