The php code below seems to run but not save into the database. Its simple yet critical enough to be a bother.
<html>
<body>
<?php
if(isset($_POST['submit'])){
$connect=mysql_connect("localhost","root","root","form2");
if(mysql_connect_error($connect))
{
echo 'Failed to cnnect';
}
$fname=$_POST['fname'];
if(mysql_query("INSERT INTO user(fname) VALUES('$fname')"))
{
echo ' Success';
}else
{
echo ' No good!';
}
}
?>
<form method ="POST">
First name <input type = "text" name = "fname"></input>
<input type = "submit" name = "submit" value ="enter"></input>
</form>
</body>
</html>
When should one use mysqli for security reasons (since mysql is deprecated) and how should it be used?