Case: a form with Name, Email and Message is posted. We want to get the values, validate and prepare a SQL query.
// Init. class $Input = new Input; $error = FALSE; // As "is_valid" returns NULL when the data is not set, // this is what we are checking. if ( ! is_null ($Input->post ('Name')->is_valid()) ) { $Name = $Input->post ('Name'); $Email = $Input->post ('Email'); $Msg = $Input->post ('Msg'); if ($Name->validate ('is_alnum')) === FALSE) { $error = TRUE; } elseif ($Email->validate ('valid_email') === FALSE) { $error = TRUE; } elseif ($Msg->value() == FALSE) { $error = TRUE; } if ($error === FALSE) { $Name = $Name->sanitize ('quote_smart'); $Email = $Email->sanitize ('quote_smart'); $Msg = $Msg->sanitize ('quote_smart'); $SQL = 'INSERT INTO foo (name, email, message) VALUES (%s, %s, %s)'; $SQL = sprintf ($SQL, $Name, $Email, $Msg); } } if ($error === TRUE) { // We have a situation. }