I'm having a problem in inserting data to my database. I don't have any clues what's the error.
Here's my index:
<form id="myForm" action="insert.php" method="post">
Name: <input type="text" name="name"/><br/>
Username: <input type="text" name="username"/><br/>
Password: <input type="password" name="password"/><br/>
<button id="sub">Save</button>
</form>
<span id="result"></span>
And here's my insert.php
:
include_once('db.php');
$name = $_POST['name'];
$username = $_POST['username'];
$password = $_POST['password'];
if(mysql_query("INSERT INTO table_users VALUES('$name', '$username', '$password')")){
echo "Successfully Inserted";
} else {
echo "Insertion Failed";
}
And my db.php
:
$conn = mysql_connect('localhost', 'root', '');
$db = mysql_select_db('neverstoplearning');