I am really new to php and I am trying to use simple insert to my mysql database from the form.
I know that this mysql connection/insertion is dangerous and not used anymore. so can anyone please help me with this simple thing? I tried to google, but nothing is working so far :/
<? 
$text=$_POST['name']; 
$text=$_POST['surename'];
mysql_connect("localhost", "db_name", "pass") or die(mysql_error()); 
mysql_select_db("db_name") or die(mysql_error()); 
$result = mysql_query("INSERT INTO `table` (name, surename)
VALUES (NOW(), '".mysql_real_escape_string($name)."', '".mysql_real_escape_string($surename)."')");
if (!$result) {
    die('Invalid query: ' . mysql_error());     
}
?>
 
     
    