Check Status or Update Report

 

[insert_php]
// form validation errors
$errors = array();

// validate the form and create a new item if this is a postback request
if($_SERVER[‘REQUEST_METHOD’] == ‘POST’)
{
ValidateForm();
}

function ValidateForm()
{
$postID = $_POST[‘iname’];

if (empty($postID)) {
$errors[‘iname’] = ‘Please enter the incident ID.’;
}

if (count($errors) == 0) {
FindPost($postID);
} else {
// highlight forms items that are invalid using javascript
echo ‘‘;
}
}

function FindPost($iname)
{
$args=array(
‘name’ => $iname,
‘post_type’ => ‘post’,
‘post_status’ => ‘publish’,
‘posts_per_page’ => 1
);
$my_posts = get_posts($args);
if ($my_posts) {
wp_redirect(‘/’ . $my_posts[0]->post_name);
exit;
} else {
echo “

The ID $iname was not found.

“;
}
}
[/insert_php]