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