Location: PHPKode > scripts > Requests > requests/example.php
<html>
<head>
<title>example page</title>
</head>
<body>
<?
  include 'class.requests.php';
  include 'adodb.inc.php';

  try {
    $requests = new Requests();
    if($requests->dataExist(METHOD_POST)) {
      // modyfying conditions values
      $requests->defineCondition(MIN_LENGHT, 3);
      $requests->defineCondition(MAX_LENGHT, 25);

      // adding conditions to fieldname
      $requests->addCondition(METHOD_POST, "id", VALID_NUMBERS);
      $requests->addCondition(METHOD_POST, "name", MIN_LENGHT);
      $requests->addCondition(METHOD_POST, "name", MAX_LENGHT);
      $requests->addCondition(METHOD_POST, "email", VALID_EMAIL);

      // test all definied conditions; on failure throws an exception;
      $requests->testAllConditions();
      
      // it's seems to be ok an we can insert data into database
      $sql = "insert into testTable(name,email) VALUES('".
             $requests->getPost("name")."', '".$requests->getPost("email").
             "') WHERE id = ".$request->getPost("id");

      $DB = NewADOConnection('mysql');
      $DB->Connect($server, $user, $pwd, $db);
      
      $result = $DB->Execute($sql);
    } else {
    	?>
    		<form action="example.php" method="POST">
    		<input type="hidden" name="id" value="233">
    		<input type="text" name="name" value=""><br>
    		<input type="text" name="email" value=""><br>
    		<input type="submit" value="Send">
    		</form>
    	<?
    }
  } catch (RequestsException $re) {
       echo "Error in sending data. Please return to form an fill it with corrent values";
  } catch (Exception $error) {
  		echo "Error: ".$error->getMessage();
  }
?>
</body>
</html>
Return current item: Requests