It would be better to include a file which contains database connection stuff instead of writing them on every page. Apart from that, a logout script like this should be sufficient enough:
<?php
session_start(); // start a session first, else you cannot destroy/unset it
session_destroy(); // destroy all sessions
header('location:index.php'); // redirect
?>
Also, as @chandresh_cool said, I hope you didn't really use "username", "password" and "database" as credentials.