验证服务器端的“选择选项”值

Would it be a good idea to check serverside whether the option values submitted from html are valid? Or am I over-engineering here?

HTML

<select name="options">
    <option value="foo">Foo</option>
    <option value="bar">Bar</option>
    <option value="baz">Baz</option>
</select>

PHP

$allowed = array('foo','bar','baz');
if(!in_array($_POST['options'], $allowed)) {
    //display error
    die();
}

you are missing ( in if statment.

if(!in_array($_POST['options'], $allowed) {
    //display error
}

use it.

if(!in_array($_POST['options'], $allowed)) {
    //display error
}