im trying to create a form that redirects the user to anther page and also stores the information in the database.
here is the code
<?php
mysql_connect("localhost", "DBname", "Password") or die(mysql_error());
mysql_select_db("DBname") or die(mysql_error());
// Retrieve all the data from the table
$result = mysql_query("SELECT * FROM players")
or die(mysql_error());
// store the record of the "player" table into $row
$row = mysql_fetch_array( $result );
?>
</div>
<table border="0" cellpadding="0" cellspacing="0" width="600">
<tr>
<td colspan="3"></td>
<td></td>
</tr>
<tr>
<td colspan="3"></td>
<td></td>
</tr>
<tr>
<td colspan="3"></td>
<td></td>
</tr>
<tr>
<td colspan=3 align=center>
<form action="main.php" method="post" name="form">
Enter Username: <input type="text" name="username" value="" ><br>
Enter Ship Name <input type="text" name="shipName" value=""><br><br>
<input type="submit" value="Im Ready">
</form>
<?php
if (isset($_POST['submit']))
{
$username = $_POST['username'];
$shipname = $_POST['shipname'];
$health = "150";
$money = "1000";
$id = $row['id'];
mysql_query("INSERT INTO players_stats (
player_id, username, shipname, char_health, ship_health, )VALUES('$id', '$username', '$shipname', '$health', '$health') ")
or die(mysql_error());
echo "Data Inserted";
} ?>
<br>
<td></td>
</tr>
<tr>
<td colspan=3 align=center><a href="#"><img src="images/mail_.gif"></a></td>
<td></td>
</tr>
<tr>
<td colspan=3 align=center><a href="faqs.html">FAQ's</a></td>
</tr>
</table></center><br><br><br><br>
<?php
include("footer.php");
?>