Writing to your database does not output anything. By output, I mean displaying to the screen. Here is how I normally go about it:
PHP Code:
<?php
if( isset( $_POST['name'] ) && isset( $_POST['phone'] ) && isset( $_POST['email'] ) ) {
//assuming open database connection
$sql = "INSERT INTO contacts ( name, phone, email ) VALUES ( '{$_POST['name']}', '{$_POST['phone']}', '{$_POST['email']}' )";
mysql_query( $sql );
header( 'location: thankyou.php' );
exit();
}
?>
<html>
<head>
<title>contact Form</title>
</head>
<body>
<form action="<?php echo $PHP_SELF; ?>" method="post">
Name:<input type="text" name="name" value="<?php echo $_POST['name']; ?>" /><br />
Phone:<input type="text" name="phone" value="<?php echo $_POST['phone']; ?>" /><br />
Email:<input type="text" name="email" value="<?php echo $_POST['email']; ?>" /><br />
<input type="submit" value="Submit" />
</form>
</body>
</html>
Of course I would do some validation on the post variables before checking to see if they are set, and adding it to the database, but hopefully this can give you a good starting point.