简体   繁体   中英

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!

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:

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

(In other words, POST has to be uppercase).

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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