I want to create PHP files dynamically. Static HTML code works fine, but when I want to insert PHP code, which contains a “window.location” command, my script directly send me to that page, without fulling the “if(isset())”-condition.
Somehow a simple echo doesn’t work. How can I fix this?
public function suche()
{
echo "if(isset(\$_POST['searchit']))
{
\$suchbegriff = \$_POST['suchbegriff'];
\$anfangsbuchstabe = substr(\$suchbegriff, 0, 1);
<script type='text/javascript' language='Javascript'>window.location = '/".$anfangsbuchstabe."/".$suchbegriff.".php'</script>
}";
}
If you are really writing to a php file that you want to call / execute later in a different request, you need to make sure the php is recognized as php, now it is just text.
So you would need something like:
Note that I have added the
phpopening and closing tags.