Hiya - Okay, So I've changed the GET to POST and these are the errors I am getting:
Notice: Undefined index: username in C:\xampp\htdocs\addusertodb.php on line 8
Notice: Undefined index: password in C:\xampp\htdocs\addusertodb.php on line 9
Notice: Undefined index: age in C:\xampp\htdocs\addusertodb.php on line 10
Notice: Undefined index: emailaddress in C:\xampp\htdocs\addusertodb.php on line 11
Column count doesn't match value count at row 1
HTML:
<center><h1 style="color:#fff;">Registration form</h1> <form action="addusertodb.php" method="POST"><table border="1" cellspacing="5" width="50%" cellpadding="5" style="border: 1px solid #B11718; color: #fff"> <tr> <td><h3>Login Details</h3></td></tr> <tr> <td>Username: <input type="text" name="username"> <td>Password: <input type="password" name="password"></tr> <tr> <td><label>Email: <input type="text" name="emailaddress"></label></td> <td><label>Age: <input type="text" name="age" size="3"></label></td> </tr> </table> <br /> <input type="submit" name="register" size="5" value="Register"></form> <a href="index.php"><input type="submit" value="Return"></a></input></center> <br />
That is the HTML form that I am using, for now I am just going to have one password field until I can get it working.
And this is the PHP form:
<?php
require "dbconn.php";
//Copy the variables that the form placed in the URL
// into these three variables
$name = $_POST['username'];
$password = $_POST['password'];
$age = $_POST['age'];
$emailaddress = $_POST['emailaddress'];
//connect to MySQL
$connect = mysql_connect($host, $user, $password )
or die ("Hey loser, check your server connection.");
//Make sure we are using the right database
mysql_select_db($database);
//set up the query using the values that were passed via the URL from the form
$query = "INSERT INTO person VALUES ('".$name."','".$password."','".$age."','".$emailaddress."')";
$results = mysql_query($query)
or die (mysql_error());
header( 'Location:registered.html');
?>