There's a fundamental problem in your code, and one that suggests you're doing something very dangerous in your code.
Given this code:
$id = 216;
$p = get_page($id);
echo apply_filters('the_content', $p->post_content);
I would expect this to be running from a template file, however, the question claims that the post content contains this:
value="<?php echo $url?>"
This is not possible in normal WordPress, so you must be using a plugin that lets you put PHP tags inside post content. This is the source of all your problems. Because of this:
- Most WordPress knowledge is unusable to you
- The vast majority of tutorials will not work as they assume you're in a template file
- Large numbers of solutions simply won't work correctly
Using plugins that let you embed PHP inside a post is extremely unusual, and super important to know. A person unaware of this will suggest things that will not work.
This is one of those situations where the answer you seek is not possible using a plugin that lets you use PHP inside a posts content.
Additionally, it's incredibly dangerous from a security point of view. But there is a much easier way that uses standard WordPress practices
Thus, I do not believe it is possible to solve your problem as long as you persist with the plugin allowing you to embed PHP inside a post. Never use something that lets you store PHP code in the database and run it from the database.
Shortcodes
If you need to embed PHP logic inside a post/page, create a shortcode.
This way, your page can be something like this:
My page!
[kristynas_form foo="bar"]
In a plugin or your themes functions.php
you can use something like this:
add_shortcode( 'kristynas_form', function( array $attributes ) {
$foo = $attributes['bar'];
return 'form HTML';
});
When the page gets rendered the shortcode gets swapped out. This is how you're supposed to implement things like iframes, forms, and other complex logic that appears inline.