<?php
$password = $_POST["password"];
if (isset($password) == true){
echo "your password = ".$password."<hr>";
echo "Encrypted password = ".md5($password)."<hr>";
}else{
echo "please enter your password";
};
echo'
<form action="index.php" method="post" >
password : <input type="password" name="password">
<input type="submit" />
';
?>
在此代码中我想使用md5函数加密用户密码
但是当用户输入任何内容时它回显
d41d8cd98f00b204e9800998ecf8427e
并使用isset函数来解决此问题,但它无法正常工作
答案 0 :(得分:0)
尝试这种方式:
$scope.quoteToAdd = {
author : $scope.quoteAuthor,
text: $scope.quoteText
};
$scope.addQuote = quoteService.addData;
}
答案 1 :(得分:0)
更改此
$password = $_POST["password"];
if (isset($password) == true){
echo "your password = ".$password."<hr>";
echo "Encrypted password = ".md5($password)."<hr>";
}else{
echo "please enter your password";
};
到这个
if (isset($_POST["password"]) == true){
$password = $_POST["password"];
echo "your password = ".$password."<hr>";
echo "Encrypted password = ".md5($password)."<hr>";
}else{
echo "please enter your password";
};
因为,当您第一次加载页面时,$_POST['password']
未设置。所以加载你的表格会遇到麻烦。
答案 2 :(得分:0)
此代码有效
<?php
$password = $_POST["password"];
if ($password == ""){
echo "please enter your password";
}else{
echo "your password = ".$password."<hr>";
echo "Encrypted password = ".md5($password)."<hr>";
};
echo'
<form action="index.php" method="post" >
password : <input type="password" name="password">
<input type="submit" />
';
?>
答案 3 :(得分:0)
实际上$_POST
解释here是通过HTTP POST传递给当前脚本的关联变量数组。因此,直接使用$_POST
本身检查任何预期变量的存在以及使用
e.g。 array_key_exists('password', $_POST);
,isset($_POST['password']);
等
换句话说,脚本中的条件可以更改为:
if (array_key_exists('password', $_POST)){
$password = $_POST["password"];
echo "your password = ".$password."<hr>";
echo "Encrypted password = ".md5($password)."<hr>";
}else{
echo "please enter your password";
};