<?php
$username = md5($_POST($username));
echo $username
$sql = "INSERT INTO table_name (username) VALUES ('$username')";
?>
<html>
<form action = "index.php" method = "post">
<input type = "text" name = "username">
<input type = "submit" name = "submit">
</form>
<html>
我想要的是,在将表单提交到已经是md5格式的数据库之后,我希望它以纯文本形式回显到页面,如:“欢迎john”。 John来自数据库,其格式为md5。
答案 0 :(得分:3)
您必须按以下方式进行: -
<html>
<form method = "POST"> <!-- form is required-->
<input type = "text" name = "username">
<input type = "password" name = "password">
<input type = "submit" value = "Submit"> <!-- a submit button -->
</form>
<html>
<?php
error_reporting(E_ALL);//check all type of errors
ini_set('display_errors',1);// display those errors
if(isset($_POST['username']) && isset($_POST['password'])){ // check both values are coming or not?
echo $username = $_POST['username']."<br/>";
echo $password = md5($_POST['password']);
}else{
echo "Please fill the form!";
}
注意: -
我不认为您将通过此代码获得任何有用的信息(因为它只是打印出值)
而不是md5
使用password_hash()
和password_verify()
。