What is the best way to insert a PHP 5 form into a MySQL database?
<form action="script.php" method="post">
<fieldset>
<input id="name" type="text" placeholder="name" />
<input type="submit" value="Opslaan" />
</fieldset>
</form>
Do I still have you use all of these?
$name= $_POST['name'];
$name = stripslashes($name);
$name = mysql_real_escape_string($name);
mysql_connect($host,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query = "INSERT INTO names VALUES ('','$name')";
mysql_query($query);
mysql_close();
Because when I do this, the script only enters the ID, the name field remains empty..
EDIT: How to use PDO or mysqli in PHP 5 (by the latest standards)?