As the subject states, I would like to add data to a database of mine by taking data that a user inserts into a form and adding it to a table.
Here is the form of my code
[code]<?php
require_once ‘login.php’;
$con = mysql_connect($db_hostname, $db_username, $db_password);
if(!$con)
{
die('Could not connect: ’ . mysql_error());
}
mysql_select_db($db_database, $con);
mysql_close($con);
?>
Add A Pokemon
Fill out the form below to create a new Pokemon in the database.
Please type your pokemon's name: Select your pokemon's type: Bug Dark Electric Fighting Fire Flying Ghost Grass Ice Psychic Steel Water Press to continue ----> [/code]and here is the back end code to actually put it into the database:
[php]
<?php require_once 'login.php'; $con = mysql_connect($db_hostname, $db_username, $db_password); if(!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db($db_hostname, $con); mysql_query("INSERT INTO Pokemon_Name (pokemonName) VALUES('$_POST[pokemon_Name]')"); mysql_query("INSERT INTO Pokemon_Type (Type) VALUES('$_POST[dropDown]')"); mysql_query("UPDATE Pokemon_Name SET pokemon_Name = pokemonName"); mysql_query("UPDATE Pokemon_Type SET pokemon_Type = Type"); echo "1 record added"; mysql_close($con); ?>[/php]