For some reason, my INSERT doesn't always work on my .php page.. even when I manually click refresh... ugg.. any ideas why?
HTML PAGE
<html>
<body>
Add Type<br /><br />
<form action="bbb.php" method="post">
<input type="text" name="typetype" />
<input type="submit" name = "submittype" value="SUBMIT" />
</form>
<?PHP
//***connection to MYSQL*
mysql_connect("localhost", "root", "mypassword");
if (! @mysql_connect) {
echo( "<p>Unable to connect to the " .
"database server at this time.</p>" );
exit();
}
//connection to the TEST database********
mysql_select_db("test");
if (! @mysql_select_db("test") ) {
echo( "<p>Unable to locate the test database at this time.</p>" );
exit();
}
$result = @("SELECT typetype FROM typetypes");
if (!$result) {
echo("<p>Error performing query: " .
mysql_error() . "</p>");
exit();
}
while ( $row = mysql_fetch_array($result) ) {
echo("<p>" . $row["typetype"] . "</p>");
}
?>
</body>
</html>
PHP PAGE
<?php
mysql_connect("localhost", "root", "mypassword");
if (! @mysql_connect) {
echo( "<p>Unable to connect to the " .
"database server at this time.</p>" );
exit();
}
mysql_select_db("test");
if (! @mysql_select_db("test") ) {
echo( "<p>Unable to locate the test database at this time.</p>" );
exit();
}
if (isset($_POST['submittype']) && $_POST['submittype'] == "SUBMIT") {
$sql = "INSERT INTO typetypes (type_id, typetype) VALUES (NULL, '" . $_POST['typetype'] . "')";
$result = mysql_query($sql);
}
header("Location: bbb.html");
?>