我需要一些代码的帮助。我有html和PHP代码,现在使用13个输入类型提交按钮。现在,我将不得不为submit1到submit13复制php isset,即使每个代码是相同的。有没有更简单的方法来使用一个isset($_POST[提交?])无论哪一种输入类型提交按钮被按下?
<?php
session_start();
global $current_user;
(get_currentuserinfo());
$link=mysqli_connect($host, $dbUsername, $dbPassword, $dbname);
$_SESSION["user_sex"] = $current_user->gender2;
$abc = "";
if (isset($_POST['submit1']))
{
$abc = "show";
$tdate = $_POST['tdate'];
$_SESSION["LeagueType_ID"] = (int)$_POST['lgType_id'];
$sql1 = "SELECT * FROM `wp_tournaments` WHERE `start_tourn` = '$tdate' AND tourn_level_type_id = $_SESSION[LeagueType_ID] ";
$ressql1 = mysqli_query($link, $sql1) or die("Bad Query: $sql1");
$_SESSION["MinAge"] = 18;
$_SESSION["Facility_ID"] = 541;
$_SESSION["Facility2_ID"] = 1520;
// League Player Dropdown - Men for Women(MX) or Same Sex for Doubles
// Needed for Men's Doubles - Male looking for male partner
if (($_SESSION["user_sex"] == "Male") and ($_SESSION["LeagueType_ID"] == 3) and ($_SESSION["MinAge"] == 18)) {
$queryPartner = "SELECT * FROM `wp_players` WHERE wp_players.gender2 = 'Male' AND region_id = 1";
}elseif (($_SESSION["user_sex"] == "Male") and ($_SESSION["LeagueType_ID"] == 3) and ($_SESSION["MinAge"] == 18)) {
$bd = reverse_birthday($_SESSION["MinAge"]);
$queryPartner = "SELECT * FROM `wp_players` WHERE wp_players.gender2 = 'Male' AND region_id = 1 AND birth_date < '$bd'";
}
// Needed for Mixed - Male looking for Female partner
if (($_SESSION["user_sex"] == "Male") and ($_SESSION["LeagueType_ID"] == 5) and ($_SESSION["MinAge"] == 18)) {
$queryPartner = "SELECT * FROM `wp_players` WHERE wp_players.gender2 = 'Female' AND region_id = 1";
}elseif (($_SESSION["user_sex"] == "Male") and ($_SESSION["LeagueType_ID"] == 5) and ($_SESSION["MinAge"] == 18)) {
$bd = reverse_birthday($_SESSION["MinAge"]);
$queryPartner = "SELECT * FROM `wp_players` WHERE wp_players.gender2 = 'Female' AND region_id = 1 AND birth_date < '$bd'";
}
// Needed for Women's Doubles - Female looking for Female partner
if (($_SESSION["user_sex"] == "Female") and ($_SESSION["LeagueType_ID"] == 4) and ($_SESSION["MinAge"] == 18)) {
$queryPartner = "SELECT * FROM `wp_players` WHERE wp_players.gender2 = 'Female' AND region_id = 1";
}elseif (($_SESSION["user_sex"] == "Female") and ($_SESSION["LeagueType_ID"] == 4) and ($_SESSION["MinAge"] == 18)) {
$bd = reverse_birthday($_SESSION["MinAge"]);
$queryPartner = "SELECT * FROM `wp_players` WHERE wp_players.gender2 = 'Female' AND region_id = 1 AND birth_date < '$bd'";
}
// Needed for Mixed Doubles - Female looking for Male partner
if (($_SESSION["user_sex"] == "Female") and ($_SESSION["LeagueType_ID"] == 5)) {
$queryPartner = "SELECT * FROM `wp_players` WHERE wp_players.gender2 = 'Male' AND region_id = 1";
}elseif (($_SESSION["user_sex"] == "Female") and ($_SESSION["LeagueType_ID"] == 5) and ($_SESSION["MinAge"] == 18)) {
$bd = reverse_birthday($_SESSION["MinAge"]);
$queryPartner = "SELECT * FROM `wp_players` WHERE wp_players.gender2 = 'Male' AND region_id = 1 AND birth_date < '$bd'";
}
$resultDbls = mysqli_query($link, $queryPartner);
// End of Tournament Player Dropdown - Men for Women(MX)
}
if (isset($_POST['submit2']))
{
$abc = "show";
$tdate = $_POST['tdate'];
$_SESSION["LeagueType_ID"] = (int)$_POST['lgType_id'];
$sql1 = "SELECT * FROM `wp_tournaments` WHERE `start_tourn` = '$tdate' AND tourn_level_type_id = $_SESSION[LeagueType_ID] ";
$ressql1 = mysqli_query($link, $sql1) or die("Bad Query: $sql1");
$_SESSION["MinAge"] = 18;
$_SESSION["Facility_ID"] = 541;
$_SESSION["Facility2_ID"] = 1520;
// League Player Dropdown - Men for Women(MX) or Same Sex for Doubles
// Needed for Men's Doubles - Male looking for male partner
if (($_SESSION["user_sex"] == "Male") and ($_SESSION["LeagueType_ID"] == 3) and ($_SESSION["MinAge"] == 18)) {
$queryPartner = "SELECT * FROM `wp_players` WHERE wp_players.gender2 = 'Male' AND region_id = 1";
}elseif (($_SESSION["user_sex"] == "Male") and ($_SESSION["LeagueType_ID"] == 3) and ($_SESSION["MinAge"] == 18)) {
$bd = reverse_birthday($_SESSION["MinAge"]);
$queryPartner = "SELECT * FROM `wp_players` WHERE wp_players.gender2 = 'Male' AND region_id = 1 AND birth_date < '$bd'";
}
// Needed for Mixed - Male looking for Female partner
if (($_SESSION["user_sex"] == "Male") and ($_SESSION["LeagueType_ID"] == 5) and ($_SESSION["MinAge"] == 18)) {
$queryPartner = "SELECT * FROM `wp_players` WHERE wp_players.gender2 = 'Female' AND region_id = 1";
}elseif (($_SESSION["user_sex"] == "Male") and ($_SESSION["LeagueType_ID"] == 5) and ($_SESSION["MinAge"] == 18)) {
$bd = reverse_birthday($_SESSION["MinAge"]);
$queryPartner = "SELECT * FROM `wp_players` WHERE wp_players.gender2 = 'Female' AND region_id = 1 AND birth_date < '$bd'";
}
// Needed for Women's Doubles - Female looking for Female partner
if (($_SESSION["user_sex"] == "Female") and ($_SESSION["LeagueType_ID"] == 4) and ($_SESSION["MinAge"] == 18)) {
$queryPartner = "SELECT * FROM `wp_players` WHERE wp_players.gender2 = 'Female' AND region_id = 1";
}elseif (($_SESSION["user_sex"] == "Female") and ($_SESSION["LeagueType_ID"] == 4) and ($_SESSION["MinAge"] == 18)) {
$bd = reverse_birthday($_SESSION["MinAge"]);
$queryPartner = "SELECT * FROM `wp_players` WHERE wp_players.gender2 = 'Female' AND region_id = 1 AND birth_date < '$bd'";
}
// Needed for Mixed Doubles - Female looking for Male partner
if (($_SESSION["user_sex"] == "Female") and ($_SESSION["LeagueType_ID"] == 5)) {
$queryPartner = "SELECT * FROM `wp_players` WHERE wp_players.gender2 = 'Male' AND region_id = 1";
}elseif (($_SESSION["user_sex"] == "Female") and ($_SESSION["LeagueType_ID"] == 5) and ($_SESSION["MinAge"] == 18)) {
$bd = reverse_birthday($_SESSION["MinAge"]);
$queryPartner = "SELECT * FROM `wp_players` WHERE wp_players.gender2 = 'Male' AND region_id = 1 AND birth_date < '$bd'";
}
$resultDbls = mysqli_query($link, $queryPartner);
// End of Tournament Player Dropdown - Men for Women(MX)
}
$def = "";
if (isset($_POST['submitform1']))
{
$def = "show";
}
$ghi = "";
if (isset($_POST['submitpaypal']))
{
$ghi = "show";
}
?>
<html>
<style type="text/css">
#box1 {
border: ridge;
color: black;
}
#box2 {
border: ridge;
color: black;
}
p {
margin-top: 5px;
margin-left: 10px;
}
div {
line-height: normal;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/chosen/1.8.7/chosen.jquery.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/chosen/1.8.7/chosen.min.css">
<script type="text/javascript"></script>
<body>
<div id="Front">
<div id = "box1">
<form method="POST">
<p>
<b>Adult Mixed Doubles Tournament</b><br/>
<br/>
<b>Adult Doubles Tournament - Men's/Women's</b><br/>
<br/>
<b>Dates:</b> April<br/>
<b>NTRP Levels:</b> 6.0, 7.0, 8.0, 9.0, 10.0 <br/>
<br/>
<b>Location:</b>Tennis Center - (555) 528-2626<br/>
<b>Address:</b> <br/>
<br/>
<b>Location:</b> Tennis Center - (555) 454-3777<br/>
<b>Address:</b><br/>
<br/>
<input type='hidden' name='lgType_id' value=5>
<input type='hidden' name='tdate' value='2020-02-27'>
<input type="submit" value="Register to Play" name="submit1">
</p>
</form>
</div>
<div id="box1">
<form method="POST">
<p>
<b>Adult Singles Tournament - Men's/Women's</b><br/>
<br/>
<b>Adult Doubles Tournament - Men's/Women's</b><br/>
<br/>
<b>Dates:</b> April<br/>
<b>NTRP Levels:</b> 6.0, 7.0, 8.0, 9.0, 10.0 <br/>
<br/>
<b>Location:</b>Tennis Center - (555) 528-2626<br/>
<b>Address:</b> <br/>
<br/>
<b>Location:</b> Tennis Center - (555) 454-3777<br/>
<b>Address:</b><br/>
<?php if ($_SESSION["user_sex"] =='Male') { ?>
<input type='hidden' name='lgType_id' value=1>
<?php } ?>
<?php if ($_SESSION["user_sex"] =='Female') { ?>
<input type='hidden' name='lgType_id' value=2>
<?php } ?>
<input type='hidden' name='tdate' value='2020-03-05'>
<input type="submit" value="Register to Play" name="submit2">
</p>
</form>
</div>
<div id="box1">
<form method="POST">
<p>
<b>Adult Doubles Tournament - Men's/Women's</b><br/>
<br/>
<b>Dates:</b> April<br/>
<b>NTRP Levels:</b> 6.0, 7.0, 8.0, 9.0, 10.0 <br/>
<br/>
<b>Location:</b>Tennis Center - (555) 528-2626<br/>
<b>Address:</b> <br/>
<br/>
<b>Location:</b> Tennis Center - (555) 454-3777<br/>
<b>Address:</b><br/>
<?php if ($_SESSION["user_sex"] =='Male') { ?>
<input type='hidden' name='lgType_id' value=3>
<?php } ?>
<?php if ($_SESSION["user_sex"] =='Female') { ?>
<input type='hidden' name='lgType_id' value=4>
<?php } ?>
<input type='hidden' name='tdate' value='2020-04-02'>
<input type="submit" value="Register to Play" name="submit3">
</p>
</form>
</div>
</div>
<div id="firstForm1">
<form method='POST'>
<h4>Adult Tournament <?php echo $tdate; echo $lgType_id; ?></h4>
<br>
<select class="chosen" name="formtournlvl" id="TournLevel" required>
<option value="">Select Your Tournament Level....</option>
<?php while($row1 = mysqli_fetch_assoc($ressql1)):;?>
<option value=<?php echo $row1['ID'];?>><?php echo $row1['description'];?></option>
<?php endwhile;?>
</select>
<br><br>
<select class="chosen" name="DblsPartner" id="selectPartner" >
<option value="">Doubles Partner Selection:</option>
<option value=0>**** Partner not Listed ****</option>
<?php
while($row1 = mysqli_fetch_assoc($resultDbls)):;?>
<option value=<?php echo $row1['id'];?>><?php echo $row1['display_name'] . " - " . $row1['user_city'] . ", " . $row1['user_state'] . ", " . $row1['user_zip'] . "";?></option>
<?php
endwhile;
?>
</select>
<br><br>
<input class="pull-right" type="submit" name="submitform1" value="Move to Step 2" required>
</form>
</div>
<div id="secondForm1">
<form method='POST'>
<h4>Page 2</h4>
<input type="submit" class="pull-right" name="submitpaypal" value="Next Step" style="margin-left:10px;">
</form>
</div>
<div id="thirdForm1">
<h4>Page 3</h4>
</div>
<?php
if($abc!=""){
?>
<script type="text/javascript">
$("#Front").hide();
$("#firstForm1").show();
$("#secondForm1").hide();
$("#thirdForm1").hide();
</script>
<?php
}elseif($def!=""){
?>
<script type="text/javascript">
$("#Front").hide();
$("#firstForm1").hide();
$("#secondForm1").show();
$("#thirdForm1").hide();
</script>
<?php
}elseif($ghi!=""){
?>
<script type="text/javascript">
$("#Front").hide();
$("#firstForm1").hide();
$("#secondForm1").hide();
$("#thirdForm1").show();
</script>
<?php
}else{
?>
<script type="text/javascript">
$("#Front").show();
$("#firstForm1").hide();
$("#secondForm1").hide();
$("#thirdForm1").hide();
</script>
<?php
}
?>
<script type="text/javascript">
$(".chosen").chosen();
</script>
</body>
</html>
我已经阅读了之前提交的一些问题,但没有找到一个与我所问的问题类似的问题。在其他问题上提交的许多答案帮助我走到了这一步。
我喜欢所有输入类型提交按钮的格式,但希望只有一个isset($_POST[提交?]PHP代码。
您可以像这样尝试所有提交按钮
if($_SERVER['REQUEST_METHOD']=="POST")
{
// access all your form data here
}
问题内容: 我有以下代码,基本上它正在执行两个操作。第一个是将我的表单数据提交到google电子表格,另一个操作是将我的第二个表单文本框值数据提交到另一个页面文本框值。这个怎么做? 从上面可以看到,这是第一页,第二页是第二种形式的Sankranthi_Reserv2.asp。我想在那儿传递文本框值,所以问题是第一种形式是提交给Google文档并存储数据,但是第二种形式需要将手机号码文本框值传递给下
问题内容: 我在表单中有两个 提交 按钮。我如何确定哪一个被击中服务器端? 问题答案: 如果给每个人起一个名字,那么被点击的人将作为其他任何输入被发送出去。
我正在尝试使用php和mysql进行在线测验/调查!我第一次使用php!我想做的是从我的数据库中获取问题和它的多项选择(测验和表格问题,其中Qid、Qtext、Ans1..Ans4作为其6列),一旦用户完成测验,就按下最后一个问题的提交按钮。。所有答案应保存在Db中(测验和表格答案,以Aid、Ans、Qid作为其列)!我搜索了相关的代码,但一个都听不懂。如果有人能帮忙,我将不胜感激。谢谢
问题内容: 我在android中启动了程序,一次活动中有3个按钮。 我看到了一些示例代码,它们为所有按钮(即使它们执行完全不同的操作)分配了相同的事件,并且在方法情况下为案例… 有什么更好的方法?一种方法和一种或多种切换方法,每个按钮一种? 谢谢。 问题答案: 如果要减少编码行,请使用;如果要单独处理所有单击(为便于理解和维护代码),请分别使用所有 更新: 如果在“活动”布局xml文件中声明了Bu
问题内容: 是否可以使用Django中的一个提交按钮提交两种不同的形式?我有一个称为“仪器”的形式和四个相等的形式“配置”。现在,我想始终提交一个配置和工具。例如instrument + config 1和instrument + config 2,并且每个配置都有自己的提交按钮。 我已经在配置表单中用一个按钮尝试过: 并调用js函数“ onclick”: 这是我在views.py中的方法: 问题
我在一个网站上有两个类似的表单,我想合并成一个有两个提交按钮的表单。他们使用大多数相同的数据。 第一个表单使用GET将数据发送到另一台服务器。第二个表单通过电子邮件发送。我想强烈鼓励网站用户在尝试选项二之前先使用选项一。 我知道如何使用javascript实现这一点,但不是以一种退化良好的方式。还有其他方法可以有两个提交选项吗?或者其他如何实现这一点的想法?谢谢