I want to do a simple registration form that stores data in the database but it doesn't seem to be working for me.
This is my html code:
<html>
<body>
<form method="post" name="register" action="register.php">
<table>
<tr>
<td>User Name:</td>
<td><input type="text" name="name"></td>
</tr>
<tr>
<td>User Email:</td>
<td><input type="text" name="email"></td>
</tr>
<tr>
<td>User Role:</td>
<td><input type="text" name="role"></td>
</tr>
<tr>
<td><input type="submit" name="SubmitForm" value="Save"></td>
</tr>
</form>
</body>
</html>
And this is my PHP code:
<?php
// Make a MySQL Connection
$user="root";
$password="my password";
$database="playtime";
$host="localhost";
$table="ttuser";
mysql_connect($host, $user, $password) or die("Connection Failed");
mysql_select_db($database) or die("Connection Failed");
$name = $_POST['name'];
$email = $_POST['email'];
$role = $_POST['role'];
// Insert a row of information into the table "ttuser"
$query = "INSERT INTO ttuser (uemail, uname, urole) VALUES('$email', '$name', '$role')";
if(mysql_query($query)){
echo "inserted";}
else{
echo "fail";}
?>
it connects to the database fine, but when I click submit on the html page it goes to php but doesn't show anything. Can someone please help ?