PHP脚本仅在首次提交后发布到db

PHP脚本仅在首次提交后发布到db,php,Php,我建立了我自己的自定义CMS后端到一个网站,我一直在工作,并已经历了一些奇怪的行为与我的网站的功能 管理员首先会看到一个表单,该表单有两个部分要填写“横幅”和“第1部分”,然后他/她可以单击屏幕一侧的按钮将新部分附加到页面,这是通过一些jQuery处理的,以将新元素附加到文档中 在此之前,脚本的行为与往常一样,所有部分都可以填写,但在提交时,脚本会抛出大量错误。如果再次输入信息,表单将按预期提交,所有正确的信息将提交到数据库。我想知道的是,jQuery是否与提交时DOM的行为方式相冲突,还是我在

我建立了我自己的自定义CMS后端到一个网站,我一直在工作,并已经历了一些奇怪的行为与我的网站的功能

管理员首先会看到一个表单,该表单有两个部分要填写“横幅”和“第1部分”,然后他/她可以单击屏幕一侧的按钮将新部分附加到页面,这是通过一些jQuery处理的,以将新元素附加到文档中

在此之前,脚本的行为与往常一样,所有部分都可以填写,但在提交时,脚本会抛出大量错误。如果再次输入信息,表单将按预期提交,所有正确的信息将提交到数据库。我想知道的是,jQuery是否与提交时DOM的行为方式相冲突,还是我在PHP脚本中犯了错误?在过去的几天里,我一直在坚持这一点,任何建议都将不胜感激

这里我们检查要渲染的视图

    <?php if(!isset($_POST['submission'])){
        include_once("includes/getsection_view.php");
    } else if(isset($_POST['submission'])){
        include_once("includes/getsection_view_return.php");
    }
?>

加价

getsection_view.php(默认视图)


第一节

我不知道这是否能解决您的主要问题,但我注意到您的代码中可能存在一个“bug”,比如使用
$\u POST['submit']
而不是
$\u POST['submission']]
,还有一个建议,即替换
$title+$I
$body+$I
这对我来说很奇怪:

...
    $title1 = "";
    $body1 = "";

    if(isset($_POST['submission'])){
         for($i=0; $i <=count($nodes); $i++)
         {
                    $title = 'title'.$i;
                    if(isset($_POST['sectionTitle'.$i])){ $$title = htmlentities($_POST['sectionTitle'.$i]);};
                    $body = 'body'.$i;    
                    if(isset($_POST['sectionContent'.$i])){ $$body = htmlentities($_POST['sectionContent'.$i]);};
            }
        }
...

                <input class="textOver" type="text" name="sectionTitle1" value="<?php echo $title1; ?>" placeholder="Section Title" onfocus="this.select();">
                <label class="inst ib">Please enter any text you would like associated with the section.</label>
                <textarea style="margin-top: 3px" name="sectionContent1" value="<?php echo $body1; ?>" onfocus="this.select();" placeholder="Section Description"></textarea>
                <label class="inst ib">Please upload the image associated with this section, .PNG required (588x514px).</label>
...
。。。
$title1=“”;
$body1=“”;
如果(isset($_POST['submission'])){

对于($i=0;$i我不知道这是否能解决您的主要问题,但我注意到您的代码中可能存在一个“bug”,比如使用
$\u POST['submit']
而不是
$\u POST['submission']
,还有一个建议,即替换
$title+$i
$body+$i
这对我来说听起来很奇怪:

...
    $title1 = "";
    $body1 = "";

    if(isset($_POST['submission'])){
         for($i=0; $i <=count($nodes); $i++)
         {
                    $title = 'title'.$i;
                    if(isset($_POST['sectionTitle'.$i])){ $$title = htmlentities($_POST['sectionTitle'.$i]);};
                    $body = 'body'.$i;    
                    if(isset($_POST['sectionContent'.$i])){ $$body = htmlentities($_POST['sectionContent'.$i]);};
            }
        }
...

                <input class="textOver" type="text" name="sectionTitle1" value="<?php echo $title1; ?>" placeholder="Section Title" onfocus="this.select();">
                <label class="inst ib">Please enter any text you would like associated with the section.</label>
                <textarea style="margin-top: 3px" name="sectionContent1" value="<?php echo $body1; ?>" onfocus="this.select();" placeholder="Section Description"></textarea>
                <label class="inst ib">Please upload the image associated with this section, .PNG required (588x514px).</label>
...
。。。
$title1=“”;
$body1=“”;
如果(isset($_POST['submission'])){

对于($i=0;$我可以请您只显示相关的代码片段吗?我知道您的意图是好的,但这太长了,其中有很多HTML内容我们根本不需要。对不起,Shomz,我会仔细查看并删除所有不相关的HTML块-我担心代码太多)你能只显示相关的代码片段吗?我知道你的意图是好的,但这太长了,里面有很多HTML内容我们根本不需要。对不起,Shomz,我会仔细查看并去掉所有不相关的HTML块-我担心代码太多了)你完全正确,我不敢相信我忽略了这一点!有时第二双眼睛会挑出最明显的错误,谢谢你,先生,欢迎你!如果这有帮助,你可以选择我的答案为正确和有用:)谢谢!你完全正确,我不敢相信我忽略了这一点!有时第二双眼睛会挑出最明显的错误,不是吗谢谢你的欢迎!如果这有帮助,你可以选择正确和有用的答案:)谢谢!
...
    $title1 = "";
    $body1 = "";

    if(isset($_POST['submission'])){
         for($i=0; $i <=count($nodes); $i++)
         {
                    $title = 'title'.$i;
                    if(isset($_POST['sectionTitle'.$i])){ $$title = htmlentities($_POST['sectionTitle'.$i]);};
                    $body = 'body'.$i;    
                    if(isset($_POST['sectionContent'.$i])){ $$body = htmlentities($_POST['sectionContent'.$i]);};
            }
        }
...

                <input class="textOver" type="text" name="sectionTitle1" value="<?php echo $title1; ?>" placeholder="Section Title" onfocus="this.select();">
                <label class="inst ib">Please enter any text you would like associated with the section.</label>
                <textarea style="margin-top: 3px" name="sectionContent1" value="<?php echo $body1; ?>" onfocus="this.select();" placeholder="Section Description"></textarea>
                <label class="inst ib">Please upload the image associated with this section, .PNG required (588x514px).</label>
...