Something like this should work.
function si_ad_call_models() {
if ( isset( $_POST['submit'] ) ) {
// Checking that $_POST['new_model_name'] is set is probably not enough validation.
if ( isset( $_POST['new_model_name'] ) ) {
// Get the stored models.
if ( get_option( 'si_ad_call_model' ) )
$si_ad_call_models = unserialize( get_option( 'si_ad_call_model' ) );
else
$si_ad_call_models = array();
// Add the new model to the end of the models array.
// @TODO Clean $_POST['new_model_name'] before adding it to database.
$si_ad_call_models[] = $_POST['new_model_name'];
// Store the updated array of models.
if ( update_option( 'si_ad_call_model', serialize( $si_ad_call_models ) ) ) {
// @TODO Tell user about success.
} else {
// @TODO Tell user about failure.
// @TODO Log database update failure.
}
} else {
// @TODO Add validation error code.
}
}
// Title of the page.
echo '<h2>Add new ad call model</h2>';
?>
<form action="" method="post">
<label for="add">Enter name of ad model: </label>
<input type="text" name="new_model_name"/>
<input type="submit" name="submit" value="Add your new ad model"/>
</form>
<?php
}
I did not fully test this code.