php - $_POST 返回空我该如何解决这个错误?
问题描述
我无法在脚本中检索我需要的值,这是我的代码:
<!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>
我得到以下信息:
“错误通知:未定义索引:在第 21 行的 /Applications/MAMP/htdocs/firstPage/index.php 中提交”
这是第 21 行:
echo $_POST['submit'];
我在这里做错了什么?我设置名称试图在单引号和双引号之间切换,但似乎没有任何效果..
提前谢谢你的答案..
解决方案
推荐阅读
- php - 关联数组键在传递给 SoapClient 时成为 XML 中的参数
- python - 如何使覆盖的 QGraphicsTextItem 可编辑和可移动?
- sql - 根据一列/SQL Oracle 中的值创建时间间隔
- excel - VBA - 您不能在此处粘贴,因为复制区域和粘贴区域的大小不同
- amazon-web-services - 从媒体转换作业/服务设置 aws s3 存储类?
- bash - 在第一行写#!/bin/bash -x,但在执行过程中没有得到任何信息
- react-native - 使用 React Native(链接)在 Instagram 上发布多张照片
- angular - 如何在RouterModule中导入有条件的模块(loadChildren)?
- node.js - Docker 的 Node-sass 构建问题
- javascript - 如何撤消javascript中的拖放?