tredjejuni;11009607 wrote:My question is why the form does not work with the expected user input?
And that's the same question that I answered above.
You talk about validation as if it has to be some afterthought, but note that if your "expected user input" happens to include a single quote, your SQL query will become broken simply because you didn't validate/sanitize the user input.
tredjejuni;11009607 wrote:As for the 'submitted' thing, what should I use then?
Whatever you want, but preferrably something that makes sense. Take a look at your form:
<form method="post" action="lena2.php" >
<INPUT type="text" name="screwtype" />
<br><INPUT type="submit" value="Start"/>
</form>
Notice there's really only one form element being POST'ed there, and it has a name of 'screwtype'. Now take a look at your PHP code:
<?php
if (isset($_POST['submitted'])) {
// form processing code here..
} //end of main if statement
?>
In other words, your processing code will only run if an element named 'submitted' exists. Notice a problem?
You either need to create an element named 'submitted' (or perhaps give that name to your submit button), or else check for the data that you actually expect to be there and need to use (e.g. 'screwtype').
Couple of other issues I notice now that I take a closer look at your latest code:
Identifiers in SQL queries (names of databases, columns, views, etc.) should not be surrounded with single quotes. Strings are to be surrounded with single quotes. For the former, either don't use any delimiter at all, or use one that is appropriate for identifiers (usually the backtick on MySQL). You have this problem in two places in your SQL query.
You're mixing functions from the [man]mysql[/man] extension with those from the [man]MySQLi[/man] extension. You can't do this - stick with one or the other (preferably the later, since the former is outdated and officially deprecated). See the manual page [man]mysqlinfo.api.choosing[/man] for more information about the different MySQL extensions (including some code examples for each).