Html表单发布,没有数据传递 [英] Html form posting, no data passed on

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

问题描述

我一直在坐这个问题一段时间,似乎无法弄清楚代码有什么问题。



问题是没有数据

 < div class =mws-panel-body> 
< form class =mws-formaction =blueprints / addmethod =postid =pForm>
< div class =mws-form-inline>
< div class =mws-form-row>
< label>蓝图名称< / label>
< div class =mws-form-item small>
< input type =textclass =mws-autocomplete mws-textinputid =pNamevalue =/>
< div>蓝图的名称,搜索完成已启用。< / div>
< / div>
< / div>
< div class =mws-form-row>
< label>机库< / label>
< div class =mws-form-item micro>
< select id =pHangar>
< option value =0selected>个人< / option>
< option value =1>公司< / option>
< / select>
< div>表示蓝图所属的人员。< / div>
< / div>
< / div>
< div class =mws-form-row>
< label>状态< / label>
< div class =mws-form-item micro>
< select id =pState>
< option value =1selected> Original< / option>
< option value =0>复制< / option>
< / select>
< div>蓝图的状态,无论是原始还是副本。< / div>
< / div>
< / div>
< div class =mws-form-row>
< label>制作运行< / label>
< div class =mws-form-item small>
< input type =textclass =mws-textinputid =pRunsvalue =0/>
< div>副本上剩余的生产运行数量。< / div>
< / div>
< / div>
< div class =mws-form-row>
< label>材质效率< / label>
< div class =mws-form-item small>
< input type =textclass =mws-textinputid =pMEvalue =0/>
< div>蓝图的当前材质效率等级。< / div>
< / div>
< / div>
< div class =mws-form-row>
< label>生产效率< / label>
< div class =mws-form-item small>
< input type =textclass =mws-textinputid =pPEvalue =0/>
< div>蓝图的当前生产效率等级。< / div>
< / div>
< / div>
< / div>
< div class =mws-button-row>
< input type =submitvalue =Add blueprintclass =mws-button blue/>
< input type =resetvalue =Resetclass =mws-button grey/>
< / div>
< / form>
< / div>

它似乎是表单本身的问题,就好像表单设置为get一样只需输入带问号的脚本, blueprints / add?,这意味着根本没有数据被传递。



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

解决方案

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

表单:

 < form action =add .phpmethod =post> 
< input type =textname =firstname/>
< / form>

脚本(add.php):

 <?php 
//打印$ _POST ['firstname']变量
echo $ _POST ['firstname'];
?>


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表单发布,没有数据传递的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆