<?php
$username = $_POST['username'];
$password = $_POST['password'];
$servername = "localhost";
$server_username = "animfqrw_loginUsername";
$server_password = "loginPassword";
$dbname = "animfqrw_userLogin";
$userID = 1;
//Connects to the mysql database
$conn = new mysqli($servername, $server_username, $server_password, $dbname);
//Ends php code if php fails to connect to mysql database
if ($conn->connect_error) {
die("Error");
break;
}
//Finds the last User_ID
$sql = "SELECT User_ID FROM Users ORDER BY User_ID DESC LIMIT 1;";
$result = $conn->query($sql);
//Fetches the last User ID so that the User ID's are all in order
while($row = $result->fetch_assoc()) {
$userID = $row["User_ID"] + 1;
}
//Add's the row to the mysql database
$sql = "INSERT INTO Users (User_ID, Username, Password)
VALUES ($userID, '$username', '$password')";
$conn->query($sql);
?>
1条答案
按热度按时间vjrehmav1#
我找到了一个使用php的解决方案,它和python中的一样好。