So I wrote a very basic PHP registration form linking in with a HTML file; here's the code in PHP:
<?php
if( $_POST )
{
$con = mysql_connect("localhost","KyleHulse","(my password)", "csdb1082");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("csdb1082", $Users);
$insert_query = "insert into feedback(
user,
password,
email
)
values (
'".$_POST['user']."',
'".$_POST['password']."',
'".$_POST['email']."')";
mysql_query($insert_query);
echo "<h2>Thanks for registering.</h2>";
mysql_close($con);
}
?>
And here's the corresponding HTML code:
<head>
<meta charset="UTF-8">
<title>Registration</title>
</head>
<body>
<form action="register.php" method="post">
<p>
<label for="user">Username</label>
<input type="text" name="user" id="user">
</p>
<p>
<label for="password">Password:</label>
<input type="text" name="password" id="password">
</p>
<p>
<label for="email">Email:</label>
<input type="text" name="email" id="email">
</p>
<input type="submit" value="Submit">
</form>
</body>
The annoying thing is I had it working earlier, something I changed caused it to break.
See Question&Answers more detail:os