All pastes #459671 Raw Edit

Unnamed

public text v1 · immutable
#459671 ·published 2007-04-26 16:43 UTC
rendered paste body
We’ll now create a new page salaryselect.html which allows the user to enter the salary to search on, instead of embedding it into the SQL code. This is straight forward HTML.

<!---	salaryselect.htm --->
<html><body>
<FORM action="salaryselect.php" method="post">
Select employees whose salary exceeds 
<input type="text" size="4" name="salary">
<input type="submit" value="Send">
</FORM>
</body></html>


Now create the page to process the user input, we’ll call it salaryselect.php
You can use the earlier example, it just needs a couple of new lines.

$sal		= $_POST[salary];
$query 	= "select empno, ename, sal from emp where sal>$sal";

The posted value from the form is picked up and placed in a variable $sal.
This variable is now used in the SELECT statement in place of the embedded number.