This is basic stuff but I can’t get this following form to process reliably. The name of the page is inplain.php. It works occasionally. The page simply lists all the values in the ‘platform’ table and allows the user to add a record and refresh.
<?
session_start();
if (!isset($_SESSION['id_customer'])) { die ("Access Denied"); }
include "../inc/db.php";
if (isset($_POST['submit'])) {
$platform = $_POST['platform'];
$created = date("Y-m-d H:i:s");
$query = "INSERT INTO Platform (id_platform, platform, date_created, date_modified) VALUES ('', $platform, '$created', '$created')";
mysql_query($query);
mysql_close();
header("Location: inplain.php");
}
echo $passage;
?>
<table cellpadding="15">
<tr>
<td valign="top" width="50%">
<?
$sell_result = mysql_query("SELECT COUNT(id_platform) FROM Platform");
$sell_count=mysql_fetch_array($sell_result);
?>
The following <?=$sell_count['COUNT(id_platform)']?> categories exist in Platform. | <a href="inlist.php">Add Game...</a>
<div style="height: 250px; overflow: auto;">
<ul>
<?
$result = mysql_query("
SELECT * FROM Platform");
while($row = mysql_fetch_array($result)) {
?>
<li>
<a href="inwant.php?addswaps=1&cat=Sell&col=sell&hid=<?=$row['id_platform']?>"><?=$row['id_platform']?></a> - <?=$row['platform']?>
<img src="../images/dot.png" width="1" height="20" border="0" />
<a href="inplain.php?remove=1&cat=Platform&col=platform&pid=<?=$row['id_platform']?>"><img src="../images/delete.jpg" width="15" height="15" border="0" alt="Delete" /></a>
</li>
<? } ?>
</ul>
</div>
</td>
</tr>
<tr>
<td>
<form name="inplain.php" method="post">
Add a new platform:
<br />
<input type="text" name="platform" size="30" /><BR>
<input type="submit" id="submit" name="submit" value="Add" />
</form>
</td>
</tr>
</table>
Thanks for the suggestions, this finally worked in the end, I added this in place of the “if (isset($_POST[‘submit’])) {“
$password = mysql_real_escape_string($_POST['password']);
if ($_POST['Submit'] == 'Add' & $password == 'xyd') {
$platform = mysql_real_escape_string($_POST['platform']);
$created = date("Y-m-d H:i:s");
$query = "INSERT INTO Platform (id_platform, platform, date_created, date_modified) VALUES ('', '$platform', '$created', '$created')";
mysql_query($query);
mysql_close();
header("Location: inplain.php");
die();
}
you need to
exitafter writing yourLocationheader. writing additional output might break the redirect.