I'm trying to get a form to be able to be submitting by hitting enter, but for some reason, it doesn't work 100%...Here's the code:
if ($Submit) // For updating the value of an item
{
$query = "UPDATE $TableName SET $Column='$NewValue' where id='$Row'";
mysql_query ($query, $Link);
print
("<script language = 'JavaScript'>
window.location = 'edit_modify.php?TableName=$TableName'
</script>");
exit;
}
print "<h2>Table: $Table</h2>";
print "<form name='Update' method='post' action='edit_update.php'>\n";
print "<p><b>Enter new value for the '$Column' element: </b>\n";
print "<input type='text' name='NewValue' size='50' value='$OldValue'>\n";
print "<input type='submit' name='Submit' value='Submit'>\n";
print "<input type='hidden' name='TableName' value='$Table'>\n";
print "<input type='hidden' name='Column' value='$Column'>\n";
print "<input type='hidden' name='Row' value='$Row'>\n";
print "</p></form>";
It works fine if the "Submit" button is pushed, but not when you hit enter.
I've determined that the cause is that the variable $Submit is null when enter is hit (even though all the other values are passed).
I can make it work by instead of checking for $Submit, check for $TableName (since the value is passed to the form orignally as $Table, and only when the form calls itself will $TableName be valid). But I would still like to know why $Submit doesn't work.