I have written a code - It takes user input and displays sha1() string for the input.
I get the 'undefined index' notice on local host even after declaring the variables and using isset() function.
Notice: Undefined index: enc in C:\Program Files\EasyPHP-12.1\www\MySQL\localhost_drupal\encrypt.php on line 61
It works fine on the remote (production) server.
What is the fault in the following code?
<?php
//variable declaration
$enc = $len = "";
// checking with isset
if(isset($_POST['enc'])) {
//sha1()
$enc = sha1($_POST['enc']);
// strlen function
$len = strlen($_POST['enc']);
}
?>
//HTML
<!DOCTYPE html>
<html>
<head><title>Generate Password</title></head>
<body>
<form name = "encry" action = "encrypt.php" method = "post">
<input type = "text" name = "enc" >
<input type = "submit" value = "Submit">
</form>
//OUTPUT
<?php
//Line 61
echo "<p> You entered :" . $_POST['enc']."</p>";
echo "<p> Length of the string you entered :" . $len. "<p>";
echo "<p> Your Password is : ". $enc . "</p>";
?>
</body>
</html>