Html 表单发布,没有数据传递

Html form posting, no data passed on(Html 表单发布,没有数据传递)
本文介绍了Html 表单发布,没有数据传递的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经解决这个问题有一段时间了,似乎无法弄清楚代码有什么问题.

问题是没有数据从表单发送到脚本.

<form class="mws-form" action="blueprints/add" method="post" id="pForm"><div class="mws-form-inline"><div class="mws-form-row"><label>蓝图名称</label><div class="mws-form-item small"><input type="text" class="mws-autocomplete mws-textinput" id="pName" value=""/><div>蓝图的名称,搜索完成已启用.</div>

<div class="mws-form-row"><label>机库</label><div class="mws-form-item micro"><select id="phangar"><option value="0" selected>个人</option><option value="1">Corporation</option></选择><div>表示蓝图属于谁.</div>

<div class="mws-form-row"><label>State</label><div class="mws-form-item micro"><select id="pState"><option value="1" selected>原始</option><option value="0">复制</option></选择><div>蓝图的状态,无论是原始还是副本.</div>

<div class="mws-form-row"><label>生产运行</label><div class="mws-form-item small"><input type="text" class="mws-textinput" id="pRuns" value="0"/><div>复制时剩余的生产运行次数.</div>

<div class="mws-form-row"><label>材料效率</label><div class="mws-form-item small"><input type="text" class="mws-textinput" id="pME" value="0"/><div>蓝图的当前材料效率水平.</div>

<div class="mws-form-row"><label>生产效率</label><div class="mws-form-item small"><input type="text" class="mws-textinput" id="pPE" value="0"/><div>蓝图的当前生产效率等级.</div>

<div class="mws-button-row"><input type="submit" value="添加蓝图" class="mws-button blue"/><input type="reset" value="Reset" class="mws-button gray"/>

</表单>

好像是表单本身的问题,好像表单设置为get,只是输入脚本只有一个问号,blueprints/add?,意思是没有数据完全被传递了.

任何指示或建议将不胜感激.

如果有帮助,我的平台是 PHP.

解决方案

您应该使用输入的 name 属性将数据发送到 PHP 后脚本.示例:

表格:

<input type="text" name="firstname"/></表单>

脚本(add.php):

I've been sitting with this problem for a while now, can't seem to figure out whats wrong with the code.

The problem is that no data gets posted from the form to the script.

<div class="mws-panel-body">
    <form class="mws-form" action="blueprints/add" method="post" id="pForm">
        <div class="mws-form-inline">
            <div class="mws-form-row">
                <label>Blueprint name</label>
                <div class="mws-form-item small">
                    <input type="text" class="mws-autocomplete mws-textinput" id="pName" value="" />
                    <div>The name of the blueprint, search completion is enabled.</div>
                </div>
            </div>
            <div class="mws-form-row">
                <label>Hangar</label>
                <div class="mws-form-item micro">
                    <select id="pHangar">
                        <option value="0" selected>Personal</option>
                        <option value="1">Corporation</option>
                    </select>
                    <div>Indicates who the blueprint belongs to.</div>
                </div>
            </div>
            <div class="mws-form-row">
                <label>State</label>
                <div class="mws-form-item micro">
                    <select id="pState">
                        <option value="1" selected>Original</option>
                        <option value="0">Copy</option>
                    </select>
                    <div>The state of the blueprint, be it original or a copy.</div>
                </div>
            </div>
            <div class="mws-form-row">
                <label>Productions runs</label>
                <div class="mws-form-item small">
                    <input type="text" class="mws-textinput" id="pRuns" value="0" />
                    <div>The number of production runs left on copy.</div>
                </div>
            </div>
            <div class="mws-form-row">
                <label>Material efficiency</label>
                <div class="mws-form-item small">
                    <input type="text" class="mws-textinput" id="pME" value="0" />
                    <div>The current material efficiency level of the blueprint.</div>
                </div>
            </div>
            <div class="mws-form-row">
                <label>Production efficiency</label>
                <div class="mws-form-item small">
                    <input type="text" class="mws-textinput" id="pPE" value="0" />
                    <div>The current production efficiency level of the blueprint.</div>
                </div>
            </div>
        </div>
        <div class="mws-button-row">
            <input type="submit" value="Add blueprint" class="mws-button blue" />
            <input type="reset" value="Reset" class="mws-button gray" />
        </div>
    </form>
</div>

It seems to be a problem with the form itself, as if the form is set to get, it just enters the script with a question-mark only, blueprints/add?, meaning no data gets passed on at all.

Any pointers or suggestions will be appreciated.

My platform is PHP if that helps.

解决方案

You should be using the name attribute of input to send the data to a PHP post script. Example:

Form:

<form action="add.php" method="post">
    <input type="text" name="firstname" />
</form>

Script (add.php):

<?php
//print the $_POST['firstname'] variable
echo $_POST['firstname'];
?>

这篇关于Html 表单发布,没有数据传递的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Convert JSON integers and floats to strings(将JSON整数和浮点数转换为字符串)
in php how do I use preg replace to turn a url into a tinyurl(在php中,如何使用preg替换将URL转换为TinyURL)
all day appointment for ics calendar file wont work(ICS日历文件的全天约会不起作用)
trim function is giving unexpected values php(Trim函数提供了意外的值php)
Basic PDO connection to MySQL(到MySQL的基本PDO连接)
PHP number_format returns 1.00(Php number_Format返回1.00)