Ir para conteúdo
Fórum Script Brasil
  • 0

[Erro] Enviar codigos html para DB


Brandow

Pergunta

Olá eu tenho um sistema de noticias em que eu uso o "tiny_mce" como editor de texto para o textarea, mas quando eu tento enviar imagens, ou colocar Bold, italic no texto nenhum funciona o que poderia ser? o campo no banco de dados? ou o tipo de variavel pois eu declarei a variavel que recebe os dados e envia como

$content = htmlspecialchars($_POST['content']);

Link para o comentário
Compartilhar em outros sites

9 respostass a esta questão

Posts Recomendados

  • 0

Poderia ver meu código e ver oque pode está errado?

<?php

if (!defined('IN_HK') || !IN_HK)
{
    exit;
}

if (!HK_LOGGED_IN || !$users->hasFuse(USER_ID, 'fuse_housekeeping_sitemanagement'))
{
    exit;
}

if (isset($_POST['content']))
{
    $title = filter($_POST['title']);
    $teaser = filter($_POST['teaser']);
    $topstory = WWW . '/images/ts/' . filter($_POST['topstory']);
    $content = $_POST['content'];
    $seoUrl = filter($_POST['url']);
    $category = intval($_POST['category']);
    
    if (strlen($seoUrl) < 1 || strlen($title) < 1 || strlen($teaser) < 1 || strlen($content) < 1)
    {
        fMessage('error', 'escreva todos os dados.');
    }
    else
    {
        dbquery("INSERT INTO site_news (title,category_id,seo_link,topstory_image,body,snippet,datestr,timestamp) VALUES ('" . $title . "','" . $category . "','" . $seoUrl . "','" . $topstory . "','" . $content . "','" . $teaser . "','" . date('d-M-Y') . "', '" . time() . "')");
        fMessage('ok', 'Noticia Criada.');
        
        header("Location: index.php?_cmd=news");
        exit;
    }
}

require_once "top.php";

?>            

<script type="text/javascript">
function previewTS(el)
{
    document.getElementById('ts-preview').innerHTML = '<img src="<?php echo WWW; ?>/images/ts/' + el + '" />';
}

function suggestSEO(el)
{
    var suggested = el;
    
    suggested = suggested.toLowerCase();
    suggested = suggested.replace(/^\s+/, ''); 
    suggested = suggested.replace(/\s+$/, '');
    suggested = suggested.replace(/[^a-z 0-9]+/g, '');
    
    while (suggested.indexOf(' ') > -1)
    {
        suggested = suggested.replace(' ', '-');
    }
    
    document.getElementById('url').value = suggested;
}
</script>

<h1>Criar nova Notícia</h1>
<form method="post">

<br />

<div style="float: left;">

<strong>Titulo:</strong><br />
<input type="text" value="<?php if (isset($_POST['title'])) { echo clean($_POST['title']); } ?>" name="title" onkeyup="suggestSEO(this.value);" style="padding: 5px; width:400; height:25; "><br />
<br />

<strong>Categoria:</strong><br />
<select name="category">
<?php

$getOptions = dbquery("SELECT * FROM site_news_categories ORDER BY caption ASC");

while ($option = mysql_fetch_assoc($getOptions))
{
    echo '<option value="' . intval($option['id']) . '" ' . (($option['id'] == $_POST['category']) ? 'selected' : '') . '>' . clean($option['caption']) . '</option>';
}

?>
</select><br />
<br />

<strong>URL-Notícia:</strong><br />
<div style="border: 1px dotted; width: 300px; padding: 5px;">
<?php echo WWW; ?>/[id]-<input type="text" id="url" name="url" value="<?php if (isset($_POST['url'])) { echo clean($_POST['url']); } ?>" maxlength="120">/<br />
</div>
<small>Isso é uma Pequena Atualização de como ficará o link da sua nótícia</small><br />
<br />

<strong>Um pequeno Texto(Frase de Efeito da nóticia):</strong><br />
<textarea name="teaser" cols="48" rows="5" style="padding: 5px; font-size: 120%;"><?php if (isset($_POST['teaser'])) { echo clean($_POST['teaser']); } ?></textarea><br />
<br />

<strong>Topstory Imagem:</strong><br />

    <select onkeypress="previewTS(this.value);" onchange="previewTS(this.value);" name="topstory" id="topstory" style="padding: 5px; font-size: 120%;">
    <?php
    
    if ($handle = opendir(CWD . '/images/ts'))
    {
        while (false !== ($file = readdir($handle)))
        {
            if ($file == '.' || $file == '..')
            {
                continue;
            }    
            
            echo '<option value="' . $file . '"';
            
            if (isset($_POST['topstory']) && $_POST['topstory'] == $file)
            {
                echo ' selected';
            }
            
            echo '>' . $file . '</option>';
        }
    }

    ?>
    </select>
    
</div>

<div id="ts-preview" style="margin-left: 20px; padding: 10px; float: left; text-align: center; vertical-align: middle;">

    <small>(Selecione a imagem TopStory para sua nóticia, que irá automáticamente irá aparecer para você ver a imagem escolhida)</small>

</div>

<div style="clear: both;"></div>

<br /><br />

<script type="text/javascript" src="./tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">
tinyMCE.init({
    mode : "exact",
    elements : "content",
    theme : "advanced",
    theme_advanced_toolbar_location : "top",
    theme_advanced_toolbar_align : "left",
    theme_advanced_resizing : true,
    theme_advanced_statusbar_location : "bottom"
});
</script>

<textarea id="content" name="content" style="width:80%"><?php if (isset($_POST['content'])) { echo clean($_POST['content']); } ?></textarea>

<br />
<br />

<input type="submit" value="Criar">

</form>


<?php

require_once "bottom.php";

?>

Link para o comentário
Compartilhar em outros sites

  • 0

Acho que é essa:

function Contains($str, $words, $filter = false)
{
    $return = false;
    
    if ($filter) {
        $str   = strtolower($str);
        $words = strtolower($words);
    }
    
    if (@strpos($str, $words) === false) {
        $return = false;
    } else {
        $return = true;
    }
    
    $getWords = explode(",", str_replace(" ", "", $words));
    
    foreach ($getWords as $Word) {
        if (!$return) {
            if (@strpos($str, $Word) === false) {
                $return = false;
            } else {
                $return = true;
            }
        }
    }
    
    return $return;
}

Link para o comentário
Compartilhar em outros sites

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152k
    • Posts
      651,7k
×
×
  • Criar Novo...