データベースにデータを保存する簡単な登録フォームを作成したいのですが、うまくいかないようです。
これは私のhtmlコードです:
<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>
そしてこれは私のPHPコードです:
<?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";}
?>
データベースに正常に接続しますが、htmlページで[送信]をクリックするとphpに移動しますが、何も表示されません。誰か助けてもらえますか?