insert.phpcreate.html
Not entirely sure if this is what you were looking for. But what this does is allows a user to submit a first name, it then add's that name to the database.
Of course you will have to change the database information as well.
PHP Code:
<?PHP
//Database Information
$dbhost = "localhost";
$dbname = "changethis";
$dbuser = "changethis";
$dbpass = "changethis";
//Connect to database
mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error());
mysql_select_db($dbname) or die(mysql_error());
$name = $_POST['name'];
// lets check to see if the username already exists
$checkuser = mysql_query("SELECT username FROM users WHERE username='$username'");
$username_exist = mysql_num_rows($checkuser);
if($username_exist > 0){
echo "I'm sorry but the name you specified has already been submitted.";
unset($name);
include 'create.html';
exit();
}
// lf no errors present with the username
// use a query to insert the data into the database.
$query = "INSERT INTO users (firstnames)
VALUES('$name')";
mysql_query($query) or die(mysql_error());
mysql_close();
echo "You have successfully Registered.";
?>
Code:
<html>
<body>
<form action="insert.php" method="post">
Firstname: <input type="text" name="name" />
<input type="submit" />
</form>
</body>
</html>
Not entirely sure if this is what you were looking for. But what this does is allows a user to submit a first name, it then add's that name to the database.
Of course you will have to change the database information as well.