I'm having (noob) trouble escaping php code within a html form that's within a php block, and would greatly appreciate help solving this.
Here's the original code before I try to escape the PHP inside the PHP. The part of it that isn't being parsed is the php block inside the div class ="control-group".
<?php if (!isset($_POST['myform'])) { echo
'<form method="POST" action="">
<fieldset>
<legend>Sign Up</legend>
<label>Username</label>
<div class="control-group'<?php if ($error) { echo ' error'; } ?>"'>';
}
<?php if (isset($myformsuccess) {
echo '<other html with more <?php ?> inside it>';
}
Here's my failed attempt at escaping the php:
<?php if (!isset($_POST['myform'])) { echo
'<form method="POST" action="">
<fieldset>
<legend>Sign Up</legend>
<label>Username</label>
<div class="control-group'<?php if (\$error) { echo \' error\'; } ?>'">';
}
I have tried to put the html inside '' and escape $ with \ (and "" when inside PHP, not shown above), but PHP is not liking this.
The reason for doing this is that rather than directing to a page after the form has been processed (validated etc, which is all working), I want to display different html replacing the original form. Once I've learned how to escape and parse the above code, I can then escape the following html and php I've left out, and do this.
Thanks