第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

將用戶重定向到頁(yè)面后如何在輸入和tinymce textarea中回顯會(huì)話變量

將用戶重定向到頁(yè)面后如何在輸入和tinymce textarea中回顯會(huì)話變量

PHP
慕尼黑8549860 2022-07-29 12:27:14
我正在嘗試處理表格。如果有錯(cuò)誤,用戶將被重定向到表單,錯(cuò)誤將在此處顯示,用戶嘗試提交的任何內(nèi)容都會(huì)在表單的 tinymce 的 textarea 中回顯。這樣,用戶就不必再次重寫(xiě)所有內(nèi)容。一切都運(yùn)行良好,除了用戶被重定向后會(huì)話變量不會(huì)在 tinymce 編輯器中回顯。會(huì)話變量已設(shè)置并具有正確的值。如果我在 tinymce 之外回顯會(huì)話變量,它會(huì)按預(yù)期顯示。它只是不會(huì)出現(xiàn)在文本區(qū)域中。我該如何解決?另外,我知道這很容易受到 xss 的影響。我想讓用戶格式化他們的帖子,所以稍后我將通過(guò) HTML Purifier 運(yùn)行它。添加新線程.php:<?php session_start(); if($_SERVER['REQUEST_METHOD']==='POST'){   if(isset($_POST['submit'])&&$_POST['submit']==='success'){    if (empty(trim($_POST['thread-title'])))    {        $_SESSION['forum_titErr'] = "<p class='error text-center'>Error message</p>";    }    else    {        $_SESSION['threadTitle'] = $_POST['thread-title'];     }    if (empty(trim($_POST['thread-content'])))    {        $_SESSION['forum_thrContErr'] = "<p class='error text-center'>Error message </p>";     }    else    {        $_SESSION['threadCont'] = $_POST['thread-content'];    }    if((isset($_SESSION['forum_titErr'])&&!empty($_SESSION['forum_titErr']))|| (isset($_SESSION['forum_thrContErr'])&&!empty($_SESSION['forum_thrContErr'])))    {        header("Location: newthread.php?submit=error");     }    else     {    //insert into database and redirect to readtopic.php if insert is successful; else redirect to form and show insert is not successful     }}else{    header("Location: newthread.php");}}else{      exit('invalid request');}?>表單html:<!DOCTYPE html><html><?php       session_start(); ?><head>    <!-- title, meta, stylesheet, etc. -->     <script type="text/javascript" src="jquery.js"></script>    <script src="https://cdn.tiny.cloud/1/no-api-key/tinymce/5/tinymce.min.js" referrerpolicy="origin"></script>    <script>tinymce.init({selector:"#threadCont", height: 300, resize: false    });</script></head>
查看完整描述

3 回答

?
繁星點(diǎn)點(diǎn)滴滴

TA貢獻(xiàn)1803條經(jīng)驗(yàn) 獲得超3個(gè)贊

我認(rèn)為你需要這樣做


 <form action='addnewthread.php' method='post'>

      <input type='text' name='thread-title' id='thread-title' placeholder='Type title here' class='user-input'

           <?php 

           if(isset($_SESSION['threadTitle']) && !empty($_SESSION['threadTitle']))

           {

                echo "value='{$_SESSION['threadTitle']}'"; 

           }

           ?>

      >

      <textarea id='threadCont' name='threadCont'>

      <?php 

            if(isset($_SESSION['threadCont']) && !empty($_SESSION['threadCont']))

            {

                 echo $_SESSION['threadCont'];

            }

      ?> 

      </textarea>

      <button id='submit' type='submit' name='submit'value='success'>Submit</button>

</form>


查看完整回答
反對(duì) 回復(fù) 2022-07-29
?
拉風(fēng)的咖菲貓

TA貢獻(xiàn)1995條經(jīng)驗(yàn) 獲得超2個(gè)贊

只需回顯變量,只需注意"and'因?yàn)樽址B接。


對(duì)于輸入:


 <input type='text' name='thread-title' id='thread-title' placeholder='Type title here' class='user-input'

 <?php 

    if(isset($_SESSION['threadTitle'])&!empty($_SESSION['threadTitle'])

     {

     echo "value='".$_SESSION['threadTitle']."'"; 

  }

  ?>

  />

對(duì)于文本區(qū)域:


  <textarea id='threadCont' name='threadCont'>

  <?php 

  if(isset($_SESSION['threadCont'])&!empty($_SESSION['threadCont'])

  {

   echo $_SESSION['threadTitle'];

  }

  ?> 

  </textarea>


查看完整回答
反對(duì) 回復(fù) 2022-07-29
?
侃侃爾雅

TA貢獻(xiàn)1801條經(jīng)驗(yàn) 獲得超16個(gè)贊

我檢查了您的代碼,發(fā)現(xiàn)您忘記添加圓括號(hào):


<form action='addnewthread.php' method='post'>

    <input type='text' name='thread-title' id='thread-title' placeholder='Type title here' class='user-input'

        <?php

        if(isset($_SESSION['threadTitle'])&&!empty($_SESSION['threadTitle']) <--here

        {

            echo "value='{$_SESSION['threadTitle']}'";

        }

        ?>

    >

    <textarea id='threadCont' name='threadCont'>

          <?php

          if(isset($_SESSION['threadCont'])&&!empty($_SESSION['threadCont']) <--and here

          {

              echo $_SESSION['threadCont'];

          }

          ?>

          </textarea>

    <button id='submit' type='submit' name='submit'value='success'>Submit</button>

</form>

您還需要替換&為&&.


查看完整回答
反對(duì) 回復(fù) 2022-07-29
  • 3 回答
  • 0 關(guān)注
  • 209 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)