将表单输入插入到数据库中,当为空时不插入为NULL

I have a form and everything works well. However when I escape the input using mysqli real_escape_string, if the input was left blank by the user, it enters blank in the database and not as NULL. here is the code I have for the variable.

    $website = '"'.$mysqli->real_escape_string($_POST['website']).'"';

The variables that are not escaped , ie a variable that is numeric and has only 7 chars appears NULL if nothing is input by the user.

Not sure what to do and Google has not been helpful.

Thanks,

Just check the value like:

$website = "NULL";

if (isset($_POST['website']))
  $website = "'" . $mysqli->real_escape_string($_POST['website']) . "'";

.. insert to db