【问题标题】:Form is not sending any data to querystring表单没有向查询字符串发送任何数据
【发布时间】:2012-05-22 14:51:21
【问题描述】:

到此为止,我已经束手无策了,我很肯定这是一些可笑的打字错误,或者我忘记写点什么了。

无论如何,我正在尝试将数据从 twitter 引导模式内的表单发送到使用 PHPMailer 脚本的名为“processed.php”的文件。 但是,当我提交表单时,没有数据传递给查询字符串,url 只是更改为 '/processed.php?'

如果有人能对此有所了解,我将不胜感激。

代码如下:

HTML 优先:

     <div class="modal-body">
        <form id="send-msg" method="GET" action="processed.php">
            <fieldset>
                <div class="control-group">
                    <label class="control-label" for="inputNavn">Navn:</label>
                    <div class="controls">
                        <input type="text" class="input-medium required" id="inputNavn">
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label" for="inputTlf">Telefon nummer:</label>
                    <div class="controls">
                        <input type="text" class="input-medium required" id="inputTlf">
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label" for="inputMsg">Besked:</label>
                    <div class="controls">
                        <textarea class="input-large required" id="inputMsg" rows="3"></textarea>
                    </div>
                </div>
                <div class="control-group">
                    <div class="controls">
                        <button type="submit" class="btn btn-primary btn-large" id="inputSend" href="#" rel="popover" data-content="Vi vender tilbage hurtigst muligt." data-original-title="Send besked" data-loading-text="Sender besked…">Send besked</button>
                    </div>
                </div>
            </fieldset>
        </form>
        <div id="results" class="alert alert-info span2">
            <p>Udfyld venligst alle felter.</p>
        </div>
    </div>

现在是 PHP:

<?php

$navn= $_REQUEST['inputNavn'];
$tlf= $_REQUEST['inputTlf'];
$besked= $_REQUEST['inputMsg'];

require_once('PHPMailer/class.phpmailer.php');
...(The rest is just the PHPMailer script)

echo $navn;
?>

无论如何,我在查询字符串中没有得到任何东西。 希望有人可以帮助我。

非常感谢!

【问题讨论】:

    标签: php html forms query-string


    【解决方案1】:

    我认为您需要将 name 属性添加到 input 以便提交值,例如

    <input type="text" class="input-medium required" id="inputNavn">
    

    应该是

    <input type="text" class="input-medium required" id="inputNavn" name="inputNavn">
    

    【讨论】:

    • 别想,这完全是真的。
    • @علیرضا 想添加更多信息以便在需要时更新答案吗?
    • 非常感谢你们的快速回答,真不敢相信我忘记了!非常感谢!
    【解决方案2】:

    您忘记为表单元素设置名称属性。

    <input type="text" class="input-medium required" id="inputNavn" name="inputNavn">
    

    【讨论】:

      【解决方案3】:

      正如 Smirkin Gherkin 所说,有必要指定一个名称。

      Id 将输入称为对象。这意味着,您可以使用 javascript 或其他语言对输入进行更新或处理。

      名称是服务器语言用来访问该输入字段上的数据的引用。

      如果我没记错的话(这是我的提示,可能是错误的):您可以使用 javascript 与输入的名称,但您不能使用 php 与输入的 id

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-08-05
        • 2012-05-12
        • 1970-01-01
        • 1970-01-01
        • 2015-04-06
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多