I want to sent some information through a from, executing a php file that should read a values.I have a form in html and there is a (declared) variable which name is $matricola.
This is a part of code that I have written:
<form action="cancella.php" method="get">
<input type="submit" name="matricola" value=' . $matricola . ' />
</form>
cancella.php is the file that should be recalled, and I want that in this php file $_GET['matricola'] will have the value written is $matricola (which is a number).
But the problem is that I display this image:
Where 10000 is the right value of $matricola, but I don't want want to display "10000" as the title of the button !!! I want just that $_GET['matricola'] will have value 10000 (of course variable and not always 10000), and put another title of the button.How do I do that?
Don't store the data in your submit button. Hide it in a hidden field.
<form action="cancella.php" method="get">
<input type="hidden" name="matricola" value=' . $matricola . ' />
<input type="submit" name="submitBtn" value="Submit">
</form>
The data will still be accessible in your PHP code the exact same way:
$matricola = $_GET['matricola'];
Be sure to filter and validate the input before using this value in database operations to avoid possible SQL Injection. Never trust input from your web application users.