我想知道我的密码,也想知道如何在php中插入出生日期或可选数据

时间:2017-11-12 13:18:32

标签: php mysql

我想在此代码中添加出生日期,性别和位置选项,此代码也有一些错误,并且还希望加密我的密码任何身体帮助

 <?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "mydb";


// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
    die("Connection failed: " . mysqli_connect_error());
}
if(isset($_POST['register-user']))
{
$name = $_POST['username'];
$email = $_POST['email'];
$password = $_POST['password'];
$gender = $_POST['gender'];
$date_of_birth = $_POST['$year'.'$day'.'$month'];

$stmt = mysqli_prepare($conn, "INSERT INTO 
mydata(name,email,Password,Gender,Country,Language) VALUES (?, ?, ?)");
mysqli_stmt_bind_param($stmt, "sss", $name, 
$email,$date_of_birth,$gender);
mysqli_stmt_execute($stmt);
}
?>

1 个答案:

答案 0 :(得分:0)

更改

$date_of_birth = $_POST['$year'.'$day'.'$month'];

$date_of_birth = $_POST['year']."-". $_POST['month']."-".$_POST['day'];

使用MD5进行密码加密

$encryptedPassword=MD5($_POST['password'])