<?php
// Determine duplicate passwords
if(trim($_POST['pwd']) != trim($ _POST['rpwd'])){
exit('The two passwords are inconsistent, please return to the previous page');
}
// Ready to write data
$username = trim($_POST['username']); // Visible data
$password = md5($_POST[' pwd']); // Visible data, md5 is a way to encrypt passwords
$time = time(); // Invisible data, returns unix timestamp , the user's registration time
$ip = $_SERVER['REMOTE_ADDR']; // Invisible data, returns the IP address, the user's registered IP, we can use ip2long to convert it to integer storage
// Connect to the database server, determine errors, select the database and set the character set
$conn = mysqli_connect('localhost', 'root', '123' );
if(mysqli_errno($conn)){
echo mysqli_error($conn);
exit;
}
echo 'success' . "<br />";}else{ echo 'failure' . "<br />";}
##?>
There is nothing wrong with the PHP code. You can print out whether the data submitted in the form exists, and then test whether the $result value exists to find errors. Also, is your database table really set to have an ID auto-increment? Anyway, I succeeded, haha
Run result:
What is the execution result?