replacing and removing data in database
Posted: Wed May 19, 2010 5:52 pm
My site is a fansite for a dragon game. People enter the draogn codes into the database. I want to let them fill out a form to update there codes in the database and remove them as well.
Here is my form for adding the codes
And here is my current add.php code
Thanks in advance 
Here is my form for adding the codes
Code: Select all
<center>
Add your dragons 4 digit code to the form<br>
<table>
<tr>
<td colspan=3>
<form method="post" action="add.php" >
Scrollname: <br>
<input type="text" name="Scrollname" size="40">
</td>
</tr>
<tr>
<td>
Egg Code:<br>
<input type="text" name="egg" size="4">
<td>
Hatchling Code:<br>
<input type="text" name="hatchling" size="4">
<td>
ER Code:<br>
<input type="text" name="er" size="4">
</td>
</tr>
<tr>
<td colspan=3>
<center><input type="submit" value="Submit">
</center>
</td>
</tr>
</table>
</form>Code: Select all
<?php
$Scrollname = $_POST['Scrollname'];
$egg = $_POST['egg'];
$hatchling = $_POST['hatchling'];
$er = $_POST['er'];
mysql_connect("localhost","","") or die ('Error: ' . mysql_error());
mysql_select_db("thehatch_dragons");
$query="INSERT INTO test (id, Scrollname, egg, hatchling, er)VALUES ('NULL', '".$Scrollname."', '".$egg."', '".$hatchling."', '".$er."')";
mysql_query($query) or die ('Error updating Database');
// Print out the contents of the entry
echo "<center>Dragons successfully added</center>";
?>