php form insert data into mysql database

Step 1 :

Make a form say xyz.html

<html>
<head>
</head>
<body>
	<form name="form1" action="abc.php" method="post">
		First Name :<input type="text" name="firstName">
		<br>
		Second Name :<input type="text" name="secondName"> 
		<input type="submit">
	</form>
</body>
</html>

Step 2 :

abc.php (to which form data is being received)

<?php

// accessing form elements
$firstName = $_POST['firstName'];
$secondName = $_POST['secondName'];

// end accessing form elements

// database connection
$db_hostname = 'localhost';
$db_database = 'db1';
$db_username = 'user';
$db_password = 'pass';

$db_server = mysql_connect($db_hostname, $db_username, $db_password);
mysql_select_db($db_database, $db_server);
if (! $db_server)
    die("Unable to connect to MySQL: " . mysql_error());
// end database connection
    
// MySql Query
$query = "INSERT INTO dummyTable VALUES ('$firstName', '$secondName')";
$result = mysql_query($query);
if (! $result)
    die("Database access failed: " . mysql_error());
// end MySql Query
?>