I am not completely sure what was the actual reason why it didn't work, but I suspect either SQL query nesting or issues with deprecated MySQL database extension.
I tested the following code and seems to be working flawlessly to me.
<?php
if (isset($_POST['submit']) && isset($_POST['Pnr']) && isset($_POST['Mobile'])) {
$hostname = "";
$username = "";
$password = "";
$database = "freepnra_userinfo";
$Pnr = $_POST['Pnr'];
$Mobile = $_POST['Mobile'];
$con = mysqli_connect($hostname, $username, $password, $database);
if (mysqli_connect_errno()) {
die("<p>Could not connect to database with the credentials passed in (" . mysqli_connect_errno() . ": " . mysqli_connect_error() . ").");
exit(1);
}
$Pnr = preg_replace("/[^0-9-]/", "", $Pnr);
$Mobile = preg_replace("/[^0-9-]/", "", $Mobile);
$sql = "INSERT INTO `users` (`pnr`, `mobile`) VALUES (?, ?)";
if ($stmt = mysqli_prepare($con, $sql)) {
mysqli_stmt_bind_param($stmt, "ss", $Pnr, $Mobile);
mysqli_stmt_execute($stmt);
mysqli_stmt_close($stmt);
}
mysqli_close($con);
}
?>
What I did, was that I nested the table name, the column names and instead of placing the variable values straight into the query, I placed double apostrophes.
I also switched to MySQLi database extension instead of your deprecated MySQL. In addition, I'd like to warn you of a very serious SQL injection problem and I fixed that issue by using prepared statements and some extra preg_replace
function just to keep all unwanted characters out of the query and table in general. I am not entirely certain of what those values should contain, so I went on assuming you want two different phone numbers (which is why I went for only allowing numbers from 0 to 9 and dashes).
Additionally, I would like to refer you to read the following material to get to know some better ways of defending your queries against potential SQL injections:
I highly recommend switching to MySQL PDO if just possible. It's very simple, easy and works a lot better in my opinion!
Hopefully this helped you out!