Let's suppose you have POSTed your html with all its quotes and stuff to a form called form.php.
Let's also suppose the html exists in the var $POST['var_var']. First, grab the value from $POST and put it in another var for convenience:
$my_var = $_POST['lastname']';
If your server is configured with magic_quotes_gpc ON then you need to remove the backslashes:
if (get_magic_quotes_gpc()) {
$my_var = stripslashes($my_var);
}
At this point $my_var should contain a pretty much verbatim version of your submitted var.
If you want to put it in to a database, you should use [man]mysql_escape_string[/man] or perhaps [man]mysql_real_escape_string[/man] or one of the newer mysqli functions to "escape" the quotes and such.
$sql = "INSERT INTO my_table (my_column) VALUES ('" . mysql_real_escape_string($my_var) . "')";