PHP代码不是';当设置为HTML表单的操作时,t将被执行
我正在创建一个具有HTML表单的网站,该表单有一个空白操作,该操作将导致该表单所在的网页,以便可以使用PHP处理该表单。PHP代码没有被执行。你能看一下我的代码,告诉我出了什么问题吗PHP代码不是';当设置为HTML表单的操作时,t将被执行,php,html,forms,execution,Php,Html,Forms,Execution,我正在创建一个具有HTML表单的网站,该表单有一个空白操作,该操作将导致该表单所在的网页,以便可以使用PHP处理该表单。PHP代码没有被执行。你能看一下我的代码,告诉我出了什么问题吗 <?php if (isset($_POST['reportsubmit'])) { $radio = $_POST['customer']; if ($radio == 'customer') { $redirect = 'Click <a href="#custome
<?php
if (isset($_POST['reportsubmit'])) {
$radio = $_POST['customer'];
if ($radio == 'customer') {
$redirect = 'Click <a href="#customer">here</a> to continue on with the form';
header('Location: #redirect');
} else if ($radio == 'item') {
$redirect = 'Click <a href="#item">here</a> to continue on with the form';
header('Location: #redirect');
} else if ($radio == 'department') {
$redirect = 'Click <a href="#department">here</a> to continue on with the form';
header('Location: #redirect');
} else if ($radio == 'person') {
$redirect = 'Click <a href="#person">here</a> to continue on with the form';
header('Location: #redirect');
}
exit;
} else if (isset($_POST['customersubmit'])) {
//process form
//redirect
exit;
} else if (isset($_POST['itemsubmit'])) {
//process form
//redirect
exit;
} else if (isset($_POST['departmentsubmit'])) {
//process form
//redirect
exit;
} else if (isset($_POST['personsubmit'])) {
//process form
//redirect
exit;
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Gordmart MIS Reports</title>
<!--<link rel="stylesheet" href="../css/Main.css">-->
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.css">
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.js"></script>
</head>
<body>
<div data-role="page" class="frame" id="report">
<div data-role="header">
<?php include("Header.php");?>
</div>
<div data-role="main" id="main">
<h3>Would you like to view a report grouped by customers, items sold, sales departments, or sales people?</h3>
<form action="" method="post">
<input type="radio" name="report" value="customer"><p>Customers</p>
<input type="radio" name="report" value="item"><p>Items Sold</p>
<input type="radio" name="report" value="department"><p>Sales Departments</p>
<input type="radio" name="report" value="person"><p>Sales People</p>
<input type="submit" name="reportsubmit" value="Submit">
</form>
</div>
<div data-role="footer">
<h1>Footer Text</h1>
</div>
</div>
<div data-role="page" class="frame" id="customer">
<div data-role="header">
<?php include("Header.php");?>
</div>
<div data-role="main" id="main">
<h3>Would you like to view a cumulative report of all customers, or a single report of just one?</h3>
<form action="" method="post">
<input type="radio" name="customer" value="all"><p>All</p>
<input type="radio" name="customer" value="one"><p>One</p><br>
<input type="submit" name="customersubmit" value="Submit">
</form>
</div>
<div data-role="footer">
<h1>Footer Text</h1>
</div>
</div>
<div data-role="page" class="frame" id="item">
<div data-role="header">
<?php include("Header.php");?>
</div>
<div data-role="main" id="main">
<h3>Would you like to view a cumulative report of all sales items, or a single report of just one?</h3>
<form action="" method="post">
<input type="radio" name="item" value="all"><p>All</p>
<input type="radio" name="item" value="one"><p>One</p><br>
<input type="submit" name="itemsubmit" value="Submit">
</form>
</div>
<div data-role="footer">
<h1>Footer Text</h1>
</div>
</div>
<div data-role="page" class="frame" id="department">
<div data-role="header">
<?php include("Header.php");?>
</div>
<div data-role="main" id="main">
<h3>Would you like to view a cumulative report of all sales departments, or a single report of just one?</h3>
<form action="" method="post">
<input type="radio" name="department" value="all"><p>All</p>
<input type="radio" name="department" value="one"><p>One</p><br>
<input type="submit" name="departmentsubmit" value="Submit">
</form>
</div>
<div data-role="footer">
<h1>Footer Text</h1>
</div>
</div>
<div data-role="page" class="frame" id="person">
<div data-role="header">
<?php include("Header.php");?>
</div>
<div data-role="main" id="main">
<h3>Would you like to view a cumulative report of all sales people, or a single report of just one?</h3>
<form action="" method="post">
<input type="radio" name="person" value="all"><p>All</p>
<input type="radio" name="person" value="one"><p>One</p><br>
<input type="submit" name="personsubmit" value="Submit">
</form>
</div>
<div data-role="footer">
<h1>Footer Text</h1>
</div>
</div>
<div data-role="page" class="frame" id="redirect">
<div data-role="header">
<?php include("Header.php");?>
</div>
<div data-role="main" id="main">
<?php echo $redirect;?>
</div>
<div data-role="footer">
<h1>Footer Text</h1>
</div>
</div>
</body>
</html>
戈德马特MIS报告
是否要查看按客户、已售出商品、销售部门或销售人员分组的报告?
顾客
出售物品
销售部门
销售人员
页脚文本
您想查看所有客户的累积报告,还是只查看一个客户的单一报告?
全部
一个
页脚文本
您想查看所有销售项目的累积报告,还是只查看一个项目的单个报告?
全部
一个
页脚文本
您想查看所有销售部门的累积报告,还是只查看一个销售部门的单个报告?
全部
一个
页脚文本
您想查看所有销售人员的累积报告,还是只查看一个销售人员的单个报告?
全部
一个
页脚文本
页脚文本
尝试下一步:
1) 对于所有形式:
将
替换为指定目标URL是最佳做法。如果你想让自己变得更健康,试试这个
<form action="<?php echo htmlentities($_SERVER['PHP_SELF']) ?>">
是$\u POST['reportsubmit']
真的吗?而且我很确定你不能重定向到锚。您需要指定页面的实际URL
页面没有进一步处理,它将尝试重定向。请尝试使用打印($\u POST)
验证是否设置了$\u POST['reportsubmit']@莱昂纳多:您喜欢如何处理标题('Location:#redirect')
#redirect
是一个html锚定,而不是一个要重定向的页面…您应该使用htmlentities()
清理该回显。检查。您应该使用htmlentities()
清理$\u服务器['self']
echo。检查
<form action="<?php echo htmlentities($_SERVER['PHP_SELF']) ?>">