So I'm actually displaying the form itself via an include on another page that is already running a SQL query pulling from the same database. The query on that page displays fine, along with the html form itself. Where I'm going wrong is, I believe, in the form12.php file. Below are snippets of the html form & then the form12.php.

snippet of the form:

 <h2>Enter a Pokemon:</h2>

 <form id="PokeEntryForm" action="form12.php" method="post">
            <label for="unique_id">ID</label>
            <input id="unique_id" name="id" type="text" value="" />
            <label for="monster_name">Name</label>
            <input id="monster_name" name="name" type="text" value="" />
            <label for="onster_type_1">Type 1</label>
            <input id="monster_type_1" name="type_1" type="text" value="" />

The name of the table in the "pokemon" database that I want to insert the form data into is "monsters".

form12.php file:



    $id = mysql_real_escape_string($_POST['id']);
    $name = mysql_real_escape_string($_POST['name']);
    $type_1 = mysql_real_escape_string($_POST['type_1']);
    $type_2 = mysql_real_escape_string($_POST['type_2']);
    $evolves = mysql_real_escape_string($_POST['evolves']);

mysql_query($dbc,"INSERT INTO monsters (poke_id, poke_name, poke_type_a, poke_type_b, evolution) VALUES ('$id', '$name', '$type_1', '$type_2', '$evolves')" 
or die(mysql_error());  
echo "Pokemon Inserted!";

echo 'Thank you for submitting a new pokemon!';


0 Answers