php form

 

 


test.php

<html>
<body>

<form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
  arg1: <input type="text" name="arg1">
  <input type="submit">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
  // collect value of input field
  $arg1 = $_POST['arg1'];
  if (empty($arg1)) {
    echo "arg1 is empty";
  } else {
    $sql = "SELECT * FROM products WHERE category_id = $arg1 AND released = 1";
    echo htmlspecialchars($sql);
  }
}
?>

</body>
</html>