[英]work with PHP_SELF
It give me this error: Undefined index: action in LINE: $act=$_POST['action'];
它给了我这个错误: Undefined index: action in LINE:
$act=$_POST['action'];
<?php
function_2()
{
?>
<FORM name="poll" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="hidden" name="action" value="insert">
.
.
.
</FORM>
<?php
}
$act=$_POST['action'];
switch($act)
{
case "insert":
function_1();
break;
default:
fuction_2();
break;
}
?>
please help me about it.请帮帮我。
That error is saying that $_POST['action']
doesn't exist.该错误表示
$_POST['action']
不存在。 So, you will need a conditional statement to set that value of $act.因此,您将需要一个条件语句来设置 $act 的值。
// Set Default
$act = '';
if ( isset($_POST['action'])) ) {
$act = $_POST['action'];
}
switch($act)
{
case "insert":
function_1();
break;
default:
fuction_2();
break;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.