php使用mysqli向数据库添加数据
$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();