我已经对我的代码进行了一些调整,现在正在运行,我只是想知道这是一个好的和安全的方式,还是我必须更改或添加代码。
<?php
session_start();
$db = mysqli_connect("localhost", "root", "", "store");
if (isset($_POST['register_btn'])) {
$username= mysqli_real_escape_string($db, $_POST['username']);
$email = mysqli_real_escape_string($db, $_POST['email']);
$pas= mysqli_real_escape_string($db, $_POST['pas']);
$stmt = $db->prepare("INSERT INTO users (username,email,pas)
VALUES(?,?,?)");
$stmt->bind_param("sss", $username, $email, $pas);
$stmt->execute();
mysqli_query($db, $stmt);
header("location: login.php");
}
?>