Here´s an example that is working for me. Very basic, but does the job. You just need to replace the values for your fields/variables/mysql to match yours
PHP Code:
<?php
$name = $_POST['name']; //pass the name from your HTML form
$email = $_POST['email']; //pass the email from your HTML form
//connect to the database
$conn=mysql_connect ("server", "user", "password") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db("name_of_your_database");
//prepare and execute the query
$data = "INSERT INTO details (name,email) VALUES ('$name', '$email')";
$result = mysql_query($data) or die(mysql_error());
//ouput information after adding
echo "Your Information Has Been Added";
?>