简体   繁体   English

未定义的变量:_Post

[英]Undefined variable: _Post

My email password script is showing error: 我的电子邮件密码脚本显示错误:

Notice: Undefined variable: _Post in C:\\xampp\\htdocs\\DreamWeaver\\EMPWScript.php on line 3 Fail - Please try again! 注意:未定义的变量:C:\\ xampp \\ htdocs \\ DreamWeaver \\ EMPWScript.php在第3行上的_Post失败-请重试!

I define the variable, what is wrong? 我定义了变量,怎么了?

<?php
    @session_start();
    $_SESSION['EMPW'] = $_Post['Email1'];
?>

You wrote: 你写了:

$_SESSION['EMPW'] = $_Post['Email1'];

but PHP is case sensitive, so try this: 但是PHP区分大小写,因此请尝试以下操作:

 $_SESSION['EMPW'] = $_POST['Email1'];

(In other words, POST has to be uppercase). (换句话说, POST必须是大写的)。

You can never be sure if it is POST or which variable type it is, so it could be better to always check and cast to the expected type. 您永远无法确定它是POST还是它的变量类型,因此最好始终检查并强制转换为期望的类型。

$empw = (string) ($_POST['email] ?? '');
//here would be nice to throw some exception if email empty
$_SESSION['EMPW'] = $_POST['Email1'];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM