制作一个表单来传递参数

Make a form to pass parameters

本文关键字:表单 参数 一个      更新时间:2023-09-26

我有一个表单,但它不会将参数"url"answers"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>

email_btn的类型应该是="submit",而不是="button",因此:

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

请参阅此处:

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

这应该与提交按钮一起使用!

(额外的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>