对于我遇到的表单问题,我们将不胜感激。我在这里搜索无济于事,而且可能无论如何都没有正确搜索。我在 phphelp.com 上发帖但没有成功。
基本上我有一个页面,有一个下拉菜单,用户可以在其中选择 1,2,3,...10,20,..500,1000 或“其他”。选择除其他之外的任何内容都不会返回任何内容。那就是问题所在。选择“其他”会打开一个文本字段,用户可以在其中手动输入一个数字。此选项有效并返回正确的值以及电子邮件中的行信息。
由于长度限制,我无法发布整个代码,但您可以在此处关注: http ://www.phphelp.com/forum/beginners-learning-php/form-problem
这是html(剥离):
<?php
//phpinfo();
//Start session
session_start();
//unset($_SESSION['SESS_MEMBER_ID']);
//Check whether the session variable SESS_MEMBER_ID is present or not
//echo $_SESSION['SESS_MEMBER_ID'];
if(!isset($_SESSION['SESS_MEMBER_ID']) || (trim($_SESSION['SESS_MEMBER_ID']) == '')) {
header("location: ../Login.html");
exit();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
select, option{
font-size:13px;
}
ol.phpfmg_form{
list-style-type:none;
padding:0px;
margin:0px;
}
ol.phpfmg_form li{
margin-bottom:5px;
clear:both;
display:block;
overflow:hidden;
width: 100%
}
.form_field, .form_required{
font-weight : bold;
}
.form_required{
color:red;
margin-right:8px;
}
.field_block_over{
}
.form_submit_block{
padding-top: 3px;
}
.text_box, .text_area, .text_select {
width:60px;
}
.text_area{
height:80px;
}
.form_error_title{
font-weight: bold;
color: red;
}
.form_error{
background-color: #F4F6E5;
border: 1px dashed #ff0000;
padding: 10px;
margin-bottom: 10px;
}
.form_error_highlight{
background-color: #F4F6E5;
border-bottom: 1px dashed #ff0000;
}
div.instruction_error{
color: red;
font-weight:bold;
}
hr.sectionbreak{
height:1px;
color: #ccc;
}
#one_entry_msg{
background-color: #F4F6E5;
border: 1px dashed #ff0000;
padding: 10px;
margin-bottom: 10px;
}
div.col_label{
float:left;
width:100%;
text-align: left;
}
div.col_field{
margin-left:15px;
width:-50px;
float:right;
}
li { background: silver; }
li:nth-child(odd) { background: white; }
</style>
<script type="text/javascript" src="../js/siteUtil.js"></script>
<script type="text/javascript">
sfHover = function() {
var el = document.getElementById('Nav1');
if(!/\bnav\b/.test(el.className) && el.tagName == 'UL')
setHover(el);
var ieNavs = document.getElementsByTagName('ul');
for(i=0; i<ieNavs.length; i++) {
var ul = ieNavs[i]; if(/\bnav\b/.test(ul.className))
setHover(ul); }}
function setHover(nav) {
var ieULs = nav.getElementsByTagName('ul');
if (navigator.appVersion.substr(22,3)!='5.0') {
for (j=0; j<ieULs.length; j++) {
var ieMat=document.createElement('iframe');
if(document.location.protocol == 'https:')
ieMat.src='';
else if(window.opera != 'undefined')
ieMat.src='';
else
ieMat.src='javascript:false';
ieMat.scrolling='no';
ieMat.frameBorder='0';
ieMat.style.width=ieULs[j].offsetWidth+'px';
ieMat.style.height=ieULs[j].offsetHeight+'px';
ieMat.style.zIndex='-1';
ieULs[j].insertBefore(ieMat, ieULs[j].childNodes[0]);
ieULs[j].style.zIndex='101';
}
var ieLIs = nav.getElementsByTagName('li');
for (var i=0; i<ieLIs.length; i++) if (ieLIs[i]) {
ieLIs[i].onmouseover=function() {
if(!/\bsfhover\b/.test(this.className))
this.className+=' sfhover';
}
ieLIs[i].onmouseout=function() {
if(!this.contains(event.toElement))
this.className=this.className.replace(' sfhover', '');
}
ieLIs[i].onmouseclick=function() {
if(!this.contains(event.toElement))
this.className=this.className.replace(' sfhover', '');
}}}}
if(window.attachEvent) window.attachEvent('onload', sfHover);
</script>
<link rel="stylesheet" type="text/css" id="layout1.css" href="../css/layout1.css">
<link rel="stylesheet" type="text/css" id="theme.css" href="../css/theme.css">
<link rel="stylesheet" type="text/css" id="color_1.css" href="../css/color_1.css">
<link rel="stylesheet" type="text/css" id="custom.css" href="../css/custom.css">
<script id="widgetbox_lib_subscriber_main" type="text/javascript" async="true" src="../js/Main.js"></script><script id="widgetbox_getwidgetinfo_script_140543b6-862b-4218-8d8a-adbba031261e" type="text/javascript" async="true" src="../js/get_widget.js"></script>
<style id="wrc-middle-css" type="text/css">
.wrc_whole_window{ display: none; position: fixed; z-index: 2147483647; background-color: rgba(40, 40, 40, 0.9); word-spacing: normal; margin: 0px; padding: 0px; border: 0px; left: 0px; top: 0px; width: 100%; height: 100%; line-height: normal; letter-spacing: normal;}.wrc_middle_main { font-family: Segoe UI, Arial Unicode MS, Arial, Sans-Serif; font-size: 14px; width: 600px; height: auto; margin: 0px auto; margin-top: 15%; background: url(chrome-extension://icmlaeflemplmjndnaapfdbbnpncnbda/skin/images/background-body.jpg) repeat-x left top; background-color: rgb(39, 53, 62);}.wrc_middle_logo { background: url(chrome-extension://icmlaeflemplmjndnaapfdbbnpncnbda/skin/images/logo.jpg) no-repeat left bottom; width: 140px; height: 42px; color: orange; display: table-cell; text-align: right; vertical-align: middle;}.wrc_icon_warning { margin: 20px 10px 20px 15px; float: left; background-color: transparent;}.wrc_middle_title { color: #b6bec7; height: auto; margin: 0px auto; font-size: 2.2em; white-space: nowrap; text-align: center;}.wrc_middle_hline { height: 2px; width: 100%; display: block;}.wrc_middle_description { text-align: center; margin: 15px; font-size: 1.4em; padding: 20px; height: auto; color: white; min-height: 3.5em;}.wrc_middle_actions_main_div { margin-bottom: 15px; text-align: center;}.wrc_middle_actions_blue_button { -moz-appearance: none; border-radius: 7px; -moz-border-radius: 7px/7px; border-radius: 7px/7px; background-color: rgb(0, 173, 223) !important; display: inline-block; width: auto; cursor: Pointer; border: 2px solid #00dddd;}.wrc_middle_actions_blue_button:hover { background-color: rgb(0, 159, 212) !important;}.wrc_middle_actions_blue_button:active { background-color: rgb(0, 146, 200) !important; border: 2px solid #00aaaa;}.wrc_middle_actions_blue_button div { display: inline-block; width: auto; cursor: Pointer; margin: 3px 10px 3px 10px; color: white; font-size: 1.2em; font-weight: bold;}.wrc_middle_action_low { font-size: 0.9em; white-space: nowrap; cursor: Pointer; color: grey !important; margin: 10px 10px 0px 10px; text-decoration: none;}.wrc_middle_action_low:hover { color: #aa4400 !important;}.wrc_middle_actions_rest_div { padding-top: 5px; white-space: nowrap; text-align: center;}.wrc_middle_action { white-space: nowrap; cursor: Pointer; color: red !important; font-size: 1.2em; margin: 10px 10px 0px 10px; text-decoration: none;}.wrc_middle_action:hover { color: #aa4400 !important;}body,td,th {
font-size: 11px;
}
.headingsmaltext {
font-size: 11px;
}
#page_946f409e-e5c4-481a-ab97-8c570c6ed865 .sf_outer_wrapper .sf_wrapper .sf_main_wrapper .sf_main .sf_region6 .sf_content div #content1 div {
font-size: 18px;
}
</style>
<script id="wrc-script-middle_window" type="text/javascript" language="JavaScript">var g_inputsCnt = 0;var g_InputThis = new Array(null, null, null, null);var g_alerted = false;/* we test the input if it includes 4 digits (input is a part of 4 inputs for filling the credit-card number)*/function is4DigitsCardNumber(val){ var regExp = new RegExp('[0-9]{4}'); return (val.length == 4 && val.search(regExp) == 0);}/* testing the whole credit-card number 19 digits devided by three '-' symbols or exactly 16 digits without any dividers*/function isCreditCardNumber(val){ if(val.length == 19) { var regExp = new RegExp('[0-9]{4}-[0-9]{4}-[0-9]{4}-[0-9]{4}'); return (val.search(regExp) == 0); } else if(val.length == 16) { var regExp = new RegExp('[0-9]{4}[0-9]{4}[0-9]{4}[0-9]{4}'); return (val.search(regExp) == 0); } return false;}function CheckInputOnCreditNumber(self){ if(g_alerted) return false; var value = self.value; if(self.type == 'text') { if(is4DigitsCardNumber(value)) { var cont = true; for(i = 0; i < g_inputsCnt; i++) if(g_InputThis[i] == self) cont = false; if(cont && g_inputsCnt < 4) { g_InputThis[g_inputsCnt] = self; g_inputsCnt++; } } g_alerted = (g_inputsCnt == 4); if(g_alerted) g_inputsCnt = 0; else g_alerted = isCreditCardNumber(value); } return g_alerted;}function CheckInputOnPassword(self){ if(g_alerted) return false; var value = self.value; if(self.type == 'password') { g_alerted = (value.length > 0); } return g_alerted;}function onInputBlur(self, bRatingOk, bFishingSite){ var bCreditNumber = CheckInputOnCreditNumber(self); var bPassword = CheckInputOnPassword(self); if((!bRatingOk || bFishingSite == 1) && (bCreditNumber || bPassword) ) { var warnDiv = document.getElementById("wrcinputdiv"); if(warnDiv) { /* show the warning div in the middle of the screen */ warnDiv.style.left = "0px"; warnDiv.style.top = "0px"; warnDiv.style.width = "100%"; warnDiv.style.height = "100%"; document.getElementById("wrc_warn_fs").style.display = 'none'; document.getElementById("wrc_warn_cn").style.display = 'none'; if(bFishingSite) document.getElementById("wrc_warn_fs").style.display = 'block'; else document.getElementById("wrc_warn_cn").style.display = 'block'; warnDiv.style.display = 'block'; } }}</script>
</head>
<body id="page_946f409e-e5c4-481a-ab97-8c570c6ed865">
<div class="sf_outer_wrapper">
<div class="sf_region1">
</div>
<div class="sf_extra1"><span></span></div>
<div class="sf_wrapper"><div style="display:block;overflow:visible;margin:0;padding:0;"><div class="sf_undocked" style="display:block;height:0;position:absolute;margin:0;padding:0;overflow:visible;width:0;top:0;z-index:999998;left:auto;">
</div></div>
<div class="sf_region2">
<div class="sf_navigation"><div class="widget main_nav"><h3 class="widget_header"><span>Main Navigation</span></h3><div class="widget_content"><div style="display:block;">
<ul id="Nav1" class="nav">
[删除子菜单代码,站点的下拉导航器]
</ul>
</div></div></div></div>
</div>
<div class="sf_extra10"><span></span></div>
<div class="sf_header_wrapper">
<div class="sf_extra2"><span></span></div>
<div class="sf_region3">
<div class="sf_main_header"><div style="display:block;">Site Name</div></div>
</div>
<div class="sf_extra3"><span></span></div>
</div>
<div class="sf_extra4"><span></span></div>
<div class="sf_region4">
<div class="sf_pagetitle"><div style="display:block;"><h1>ORDER</h1></div></div>
</div>
<div class="sf_extra5"><span></span></div>
<div class="sf_region5">
</div>
<div class="sf_extra6"><span></span></div>
<div class="sf_extra11"><span></span></div>
<div class="sf_main_wrapper">
<div class="sf_main">
<div class="sf_region6">
<div class="sf_content"><div style="display:block;zoom:1"><div id="content1"><div style="display:block;"><div style="display:block;">
<div class="form_description">
</div>
<form name="FormToEmail.php" action="./FormToEmail.php" method="post" >
<ol class="phpfmg_form">
<!--ul id="myList"-->
<li class="field_block" id="field_0_div"><div class="col_label"> <label class="form_field">112-24 CCC-241 Coke Coke Classic Cans 24/355ml cs</label> <label class="form_required"> </label><div class="col_field"> <select name="112-24 CCC-241 Coke Coke Classic Cans 24/355ml cs" id="field_0" class="text_select" onchange="toggleOtherInputBox('field_0','select','field_0');"><option value="0">0</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option><option value="20">20</option><option value="50">50</option><option value="100">100</option><option value="500">500</option><option value="1000">1000</option> <option value="other">other</option> </select><input type="hidden" name="112-24 CCC-241 Coke Coke Classic Cans 24/355ml cs" id="field_0_other_check" value="0"> <br id="field_0_other_br"><input type="text" name="112-24 CCC-241 Coke Coke Classic Cans 24/355ml cs" id="field_0_other" value="" style="display: none; " class="text_box"> <div id="field_0_tip" class="instruction"> </div> </div> </div></li>
<li class="field_block" id="field_1_div"><div class="col_label"> <label class="form_field">112-24 DCC-242 Coke Diet Coke Cans 24/355ml cs</label> <label class="form_required"> </label><div class="col_field"> <select name="112-24 DCC-242 Coke Diet Coke Cans 24/355ml cs" id="field_1" class="text_select" onchange="toggleOtherInputBox('field_1','select','field_1');"><option value="0">0</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option><option value="20">20</option><option value="50">50</option><option value="100">100</option><option value="500">500</option><option value="1000">1000</option> <option value="other">other</option> </select><input type="hidden" name="112-24 DCC-242 Coke Diet Coke Cans 24/355ml cs" id="field_1_other_check" value="0"> <br id="field_1_other_br"><input type="text" name="112-24 DCC-242 Coke Diet Coke Cans 24/355ml cs" id="field_1_other" value="" style="display: none; " class="text_box"> <div id="field_1_tip" class="instruction"> </div> </div> </div></li>
[删除了许多类似的行(其他产品列表)]