1

I can't retrieve the values I need in my script, here's my code:

<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8">
    <title>LUCAS</title>
  </head>
  <body>
    <h1>MD5 CRACKER EXERCISE:</h1>
    <p>crack the hash value into a 4 digit pin:</p>
    <form action="index.php" method="get">
      <input type="text" name='md5' size="40" value="">
      <input type="submit" name='submit' value="crack">
    </form>
<?php


  $pin = NULL;
  $hashedValue = $_GET['md5'];
  echo "Debug Output: ";

  echo $_POST['submit'];

if (isset($_POST['submit'])){
    echo "string";
    for ($i = 0; $i <= 9999; $i ++){
      if ($i < 15){
        echo hash("md5",strval($i));
      };

      if (hash("md5",strval($i)) == hash("md5",strval($hashedValue))) {
        echo $i." correct value";
        break;
      };

    };
  };

  $result = $pin ?? "not found";
  echo "<br><br>PIN:".$result;

 ?>

  </body>
</html>

I got the following:

" error Notice: Undefined index: submit in /Applications/MAMP/htdocs/firstPage/index.php on line 21"

that's the line 21:

 echo $_POST['submit'];

what am I doing wrong here? I set the name tried to switch between single and double quotes but nothing seems to work..

thank you in advance for the answers..

Lucas
  • 447
  • 5
  • 10

0 Answers0