title: Undefined array in php
body: <p><a href="https://i.stack.imgur.com/qvrax.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qvrax.png" alt="Here is the screenshot of error which I'm getting" /></a></p>
  <p>Form code</p>
  <pre><code>&lt;form action=&lt;?=$_SERVER['PHP_SELF']?&gt; method=&quot;POST&quot; id=&quot;form1&quot;&gt;
  Enter length of password:&lt;input type=&quot;text&quot; name=&quot;length&quot;&gt;
  &lt;input type=&quot;submit&quot; value=&quot;Submit&quot;/&gt;
  </code></pre>
     
  <p>PHP code</p>
  <pre><code>    &lt;?php 
      $length=$_POST['length']
      ?&gt;
  </code></pre>
  <p>Error:</p>
  <blockquote>
  <p>Undefined array key &quot;length&quot; in D:\XWAMP\htdocs\pg\index2.php on line 30</p>
  </blockquote>
  <p>I'm writing both html and php in single file that's why it's happening but how to handle it?</p>