创建一个表单来传递参数

时间:2014-10-05 15:08:24

标签: javascript php forms

我有一张表格,但它没有通过参数' url'和' USERNAME'到下一页。有什么不对吗?

我必须使用<button>代替<input>来解决样式问题。

以下是表格:

<form action="/confirmation/index.php" method="post" class="form-wrap">
<div class="loader-wrap">
<div class="loader-txt">
</div>
</div>

<div class="field-set url-field">
<input type="text" name="url" data-placeholder="Your Website URL" maxlength="50" class="validate">. 
<button name="url_btn" type="button" class="btn url-btn">Scan My Site!</button>
</div>

<div class="field-set email-field">
<input type="text" name="USERNAME" data-placeholder="Your E-mail" maxlength="50" class="validate">
<button name="email_btn" type="button" class="btn email-btn" style="width:174px;font-size:15px;">Send me Results!</button>
</div>
</form>

2 个答案:

答案 0 :(得分:5)

email_btn应为type =&#34;提交&#34;而不是type =&#34; button&#34;,而是:

<button type="submit">Send me the results</button>

见这里:

http://www.w3schools.com/tags/tag_button.asp

答案 1 :(得分:-1)

这应该适用于提交按钮!

(额外的PHP是为了表明它有效!)

<?php

if (isset($_POST['submitted'])) {
    echo "form submitted";
}
?>

<form action="index.php" method="post" class="form-wrap">
    <div class="loader-wrap">
        <div class="loader-txt">
        </div>
    </div>

    <div class="field-set url-field">
        <input type="text" name="url" data-placeholder="Your Website URL" maxlength="50" class="validate">. 
        <button name="url_btn" type="button" class="btn url-btn">Scan My Site!</button>
    </div>

    <div class="field-set email-field">
        <input type="text" name="USERNAME" data-placeholder="Your E-mail" maxlength="50" class="validate">
        <button name="email_btn" type="button" class="btn email-btn" style="width:174px;font-size:15px;">Send me Results!</button>
        <button name="submitted" type="submit">Send me the results</button> //Submit Button 
    </div>
</form>