提交按钮不在IE/Safari中工作,在Chrome中工作,信息传递

Ale*_*lex 1 php forms submit

我有一个令我困惑的奇怪问题.我有一个自制的内容管理系统,对于大多数CRUD操作,通过检查数据库中存在哪些字段,以用户友好的方式输出以编辑内容,然后将该内容提交回数据库.这些操作在Chrome中完美运行,但是在Internet Explorer和Safari中,只要我点击提交按钮,页面似乎就会刷新而不处理任何信息.

function createInsertForm($table, $formDesc, $carry, $carryUrl, $ext='', $formAppend='')
{
    // init globals
    global $cmsdir;
    global $pluginsdir;
    // put it together
    echo '<script type="text/javascript" src="' . $pluginsdir . 'ckfinder/ckfinder.js"></script><script type="text/javascript" src="' . $pluginsdir . 'ckeditor/ckeditor.js"></script>';
    echo '<form action="' . $_SERVER['PHP_SELF'] . '" method="POST" class="form-horizontal" '.$formAppend.'>';
    createForm($table, 'insert', $formDesc);
    createFormButtons('yes', 'yes');
    if ($_POST['submit'] == 'Submit') {
        insertIntoDb($table, $carry, $carryUrl, $ext);
    }
    echo '</form>';
}

function createFormButtons($submit, $reset)
{
    echo '<div class="form-actions-min">';
    if ($submit == 'yes') {
        echo '<input name="submit" type="submit" id="submit" class="btn btn-success">';
    }
    if ($reset == 'yes') {
        echo '<input name="reset" type="reset" id="reset" class="btn btn-warning btn-space">';
    }
    echo '</div>';
}
Run Code Online (Sandbox Code Playgroud)

页面输出示例:

<script type="text/javascript" src="../../neou_cms/plugins/ckfinder/ckfinder.js"></script>
<script type="text/javascript" src="../../neou_cms/plugins/ckeditor/ckeditor.js"></script>
    <form action="/neou_cms/external_forms/testimonial.php" method="POST" class="form-horizontal" >
        <div class="form-desc"></div>
        <h3>Input Fields</h3>
        <div class="control-group">
            <label class="control-label">Name</label>
            <div class="controls">
                <input type="text" name="name" value="" class="input-xlarge" id="tag_name" /></div>
        </div>
        <div class="control-group">
            <label class="control-label">Position</label>
            <div class="controls">
                <input type="text" name="position" value="" class="input-xlarge" id="tag_position" />
            </div>
        </div>
        <div class="control-group">
            <label class="control-label">Company</label>
            <div class="controls">
                <input type="text" name="company" value="" class="input-xlarge" id="tag_company" />
            </div>
        </div>
        <h3>Content Fields</h3>
        <div class="control-group">
            <label class="control-label">Quote</label>
            <div class="controls">
                <textarea name="quote" id="quote" rows="8" style="width:305px;"> </textarea>
            </div>
        </div>
        <input type="hidden" name="id" value="175013988" />
        <div class="form-actions-min"><input name="submit" type="submit" id="submit" class="btn btn-success">
            <input name="reset" type="reset" id="reset" class="btn btn-warning btn-space">
        </div>
    </form>
</div>
Run Code Online (Sandbox Code Playgroud)

我希望我能更具体,并提供更好的概述,但这需要很长时间!有没有人有过这样的问题的经验,或者可能从我的简短代码中知道可能出错的地方?

Sea*_*ira 9

您遇到的问题是您没有value<input type="submit">按钮指定.由于您未指定值,因此用户代理可以自由使用他们选择的任何值作为其默认标签.在Chrome中,它是"提交".在IE和Safari中,它是"提交查询".

避免此问题的方法是向元素添加value属性input:

<input type="submit" id="submit" value="Submit">
Run Code Online (Sandbox Code Playgroud)