This is not connecting to database anyway. I was inserting data on compile time with almost same code by commenting $_POST
portion.
No errors are showing on Netbeans IDE. My database image: https://i.stack.imgur.com/UGVsG.jpg
Could it be a MySQL configuration problem in my computer?
<?php
$server = '127.0.0.1';
$userid = 'root';
$pass = '';
$db = 'test';
$con = mysqli_connect($server, $userid, $pass, $db) or die(mysqli_error($con));
if(isset($_POST['submit']))
{
$username= $_POST['uid'];
$password= $_POST['pass'];
$sql="insert into users values ($username,$password)";
mysqli_query($con, $sql);
}
?>
<html>
<head>
<meta charset="UTF-8">
<title>Register</title>
</head>
<body>
<form method="POST" action="index.php" >
<table>
<tr>
<td>UserName : </td>
<td><input type="text" placeholder="Choose a unique username" name="uid"></td>
</tr>
<tr>
<td>Password :</td>
<td><input type="password" placeholder="Choose a suitable password" name="pass"></td>
</tr>
<tr>
<td><button type="submit" value="submit" name="submit">Register</button></td>
</tr>
</table>
</form>
</body>
</html>