开发者

How to keep textarea from duplicating text when saved in PHP?

Sorry i don't really know anything about PHP, what im trying to do is have a options page on my WordPress site where you can enter code in a text area and then it will show up in the section of my pa开发者_StackOverflow社区ges and everything is working (probably not right but working) except im trying to have <style type=\"text/css\"></style> show up inside the textarea without having to Manually put them there. This is how i have it now but the style tags keep duplicating when i save. eg.<style type=\"text/css\"></style> save then it shows <style type=\"text/css\"></style><style type=\"text/css\"></style>in the textarea.

array(  'name' => 'Header CSS ',
        'desc' => 'Add your own css between the <style> tags.',
        'id' => 'nrg_header_css',
        'type' => 'textarea'),

<textarea name="nrg_header_css" rows=8 style="width: 98%;"><?php echo stripslashes(nrg_get_option_setting('nrg_header_css')); ?><style type=\"text/css\"></style></textarea>
        <br />
        <p class="submit">
         <input name="<?php echo($actname); ?>" type="submit" value="<?php echo($flabel); ?>" />    
         <input type="hidden" name="action" value="<?php echo($actname); ?>" />
        </p>

Thanks


Try changing:

<textarea name="nrg_header_css" rows=8 style="width: 98%;">
<?php echo stripslashes(nrg_get_option_setting('nrg_header_css')); ?>
<style type=\"text/css\"></style>
</textarea>

to

<textarea name="nrg_header_css" rows=8 style="width: 98%;">
<?php
$content = stripslashes(nrg_get_option_setting('nrg_header_css'));
if($content=='')
{
    echo '<style type=\"text/css\"></style>';
}
else
{
    echo $content;
}
?>
</textarea>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜