【问题标题】:Chrome and Opera delete record data when editing a recordChrome 和 Opera 在编辑记录时删除记录数据
【发布时间】:2018-06-05 11:57:10
【问题描述】:

我是php和mysql的新手,我正在使用像CMS这样的脚本,我的问题是我可以写新文章,但是在chrome或opera上编辑它时,所有文章内容都没有显示出来进行编辑和删除Firefox 不是这样,在编辑 php 脚本下方,

<?php echo link_tag('assets/themes/' . $this->selected_theme . '/'.UIKIT_VERSION.'/css/' . $this->session->userdata('selected-theme')); ?>
<script src="<?php echo base_url() ?>assets/themes/<?php echo $this->selected_theme . '/ckeditor/ckeditor.js'; ?>"></script>
<h4><i class="uk-icon-edit"></i> edit step </h4>
<hr class="uk-article-divider">
<?php $this->load->view('user/template/default/flash_data') ?>
<?php
$attributes = array(
    'method' => 'post',
    'class' => 'uk-form'
);
echo form_open_multipart('articles/edit/' . $step->step_id, $attributes) ?>
<div class="uk-form-controls">
    <label class="uk-form-label">
        <?php if ($step->step_photo_url) { ?>
            <img src="<?php echo $step->step_photo_url ?>" class="uk-thumbnail-small"/><br/>
        <?php } else { ?>
            <i class="uk-icon-image uk-icon-large"></i>
        <?php } ?>

    </label><br/>
    <input type="file" name="step_photo_url"/>
    <br/>
    <label class="uk-form-label uk-text-muted uk-text-bold">Or Enter a URL</label>
    <input class="uk-width-90 uk-form-large" type="text" placeholder="Image Url" name="step_photo_url"
           value="<?php echo set_value('step_photo_url', $step->step_photo_url, true) ?>"/>
    <?php echo form_error('step_photo_url') ?>
</div>
<div class="uk-form-controls uk-margin-top">
    <div class="uk-form-controls uk-margin-bottom">
        <input value="<?php echo $step->step_title ?>" name="step_title" class="uk-width-90 uk-form-large"
               type="text" placeholder="step title">
        <?php echo form_error('step_title'); ?>
    </div>
    <div class="uk-margin-bottom uk-form-controls">
            <textarea name="step_description" rows="4" class="uk-width-90 uk-form-large ckeditor"
                      placeholder="Enter Description"><?php echo set_value('step_description', $step->step_description,
                    true) ?></textarea>
        <?php echo form_error('step_description'); ?>
    </div>
    <a href="<?php echo site_url('articles/delete/' . $step->step_id) ?>"
       class="uk-button uk-button-danger uk-float-left">Delete</a>
    <button class="uk-button uk-button-success uk-float-right">Save</button>
</div>
</form>

【问题讨论】:

    标签: php mysql google-chrome


    【解决方案1】:

    这是一个很难猜测的问题,尽管这听起来像是我第一次开始使用 PHP 和数据库时犯的一个错误。那就是使用htmlspecialchars($value,ENT_QUOTES) 转换值字段中的输出。如果你有这个值:

    $content = '"What are you talking about?" she asked, "that is ridiculous!"';
    

    然后您回显到输入字段进行编辑:

    <input name="test" value="<?php echo $content ?>" />
    

    html 输出为:

    <input name="test" value=""What are you talking about?" she asked, "that is ridiculous!"" />
    

    它有两组引号,然后大多数浏览器都会将该字段显示为空白。然后,当您单击更新时,它会清除您以前拥有的内容。为了解决这个问题,您应该使用:

    <input name="test" value="<?php echo htmspecialchars($content,ENT_QUOTES) ?>" />
    

    然后在该字段中为您提供以下输出:

    "What are you talking about?" she asked, "that is ridiculous!"
    

    但 html 看起来像这样:

    <input name="test" value="&quot;What are you talking about?&quot; she asked, &quot;that is rediculous!&quot;" />
    

    根据您的描述和个人经验,这只是暗中尝试。您必须显示您的 html 或一些 php 值以获得更清晰的图片。

    【讨论】:

    • 谢谢你的回答,其实我没有明白你的想法,请你在我的代码上说明一下好吗?谢谢
    • 好吧,老实说,我只是根据您所描述的内容进行猜测。当你说它被删除时,你的意思是一列的内容被删除了?
    猜你喜欢
    • 2016-08-18
    • 1970-01-01
    • 1970-01-01
    • 2020-11-20
    • 2019-04-08
    • 2021-08-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多