Display post by select it from a dropdown menu

To fix this issue, move the closing curly brace } for the foreach loop before the add_shortcode function, like this:

function form_creation(){ ?>
<select name="page_id" id="page_id">
 <?php
 global $post;
 $args = array('cat'=>19);
 $posts = get_posts($args);
 foreach( $posts as $post ) : setup_postdata($post); ?>
                <option value="<? echo $post->ID; ?>"><?php the_title(); ?></option>
 <?php endforeach; ?> <!-- Move this here -->
 </select>
<?php
            $my_postid = $post->ID;
            $content_post = get_post( $my_postid);
            $content = $content_post->post_content;
            $content = apply_filters('the_content', $content);
            $content = str_replace(']]>', ']]&gt;', $content);
            echo $content;

                         ?>
<?php } add_shortcode('r', 'form_creation');

This should ensure that each dropdown menu option corresponds to its own post content.