[nycphp-talk] Can code be executed in a heredoc?
webapprentice at mail.com
webapprentice at mail.com
Tue Feb 17 00:11:31 EST 2004
Hello,
I wanted to use a heredoc, because it was easy to send out formatted text. So, I was using this function I created to print out an HTML form and reuse it on postback. I know that in a heredoc, simple variables can be resolved. But I ran into a situation where I need to display a different dropdown depending on the value of this dropdown on postback (or if the $_POST doesn't exist).
The example below is what I was trying to do. Instead, PHP displayed the if statement as text.
Does anybody have suggestions? I could try to check the dropdown value outside this function and fill a variable with an HTML string and then insert in the heredoc.
Thanks,
Stephen
----------------------------
function printForm()
{
global $errorMessage;
echo <<< UPLOADFORM
<p>* denotes a required field.</p>
<form action="$_SERVER[PHP_SELF]" method="post" enctype="multipart/form-data">
<table cellpadding="5" cellspacing="5" class="submissionstable">
<tr>
<td class="submissionfieldname">Name *:</td>
<td class="submissionerrorfield"><input type="text" name="username" size="30" value="$_POST[username]" /> $errorMessage[username]</td>
</tr>
<tr>
<td class="submissionfieldname"> </td>
<td style="color: #ffffff; font-family: arial, helvetica, sans-serif, verdana; font-size: 10pt; text-align: left;"><br />
I am submitting ...
if isset($_POST[lyricstype])
{
<select name="lyricstype">
if ($_POST[lyricstype] == "none")
{
<option value="none" selected="selected">neither a romanization or translation</option>
}
else
{
<option value="none">neither a romanization or translation</option>
}
if ($_POST[lyricstype] == "romanization")
{
<option value="romanization" selected="selected">a romanization</option>
}
else
{
<option value="romanization">a romanization</option>
}
if ($_POST[lyricstype] == "translation")
{
<option value="translation" selected="selected">a translation</option>
}
else
{
<option value="translation">a translation</option>
}
</select>
}
else
{
<select name="lyricstype">
<option value="none" selected="selected">neither a romanization or translation</option>
<option value="romanization">a romanization</option>
<option value="translation">a translation</option>
</select>
}
<br />
<br /></td>
</tr>
</table>
</form>
UPLOADFORM;
} // End function printForm()
--
___________________________________________________________
Sign-up for Ads Free at Mail.com
http://promo.mail.com/adsfreejump.htm
More information about the talk
mailing list