I am unable to insert data. The error is:
Error: Unknown column \'\' in \'field list\'
It is simpy an HTML form page and data
You are using backticks[used for columns] for variables. Make use of single quotes. Try the below code
$sql="INSERT INTO registration (enrollno, fname, lname, fathername, coursename, yearsem, facultyno, hostel, roomno, email, mobileno, peradd, district, state, amount, pwd, tnc) VALUES ('$enrollno','$fname','$lname','$fathername','$coursename','$yearsem','$facultyno','$hostel','$roomno','$email','$mobileno','$peradd','$district','$state','$amount','$pwd','$tnc')";
The values in the INSERT INTO
query must be enclosed with single quotes '
not backticks and not a mixture of both. Backticks can only be used on the field and table name.
$sql="INSERT INTO registration (enrollno, fname, lname, fathername, coursename, yearsem, facultyno, hostel, roomno, email, mobileno, peradd, district, state, amount, pwd, tnc) VALUES ('$enrollno','$fname','$lname','$fathername','$coursename','$yearsem','$facultyno','$hostel','$roomno','$email','$mobileno','$peradd','$district','$state','$amount','$pwd','$tnc')";
Side note: your code is vulnerable to SQL Injection. Consider using a Prepared Statement with bound parameters instead of concatenating user input into the query.