php 如何创建用户名,年龄,地址,移动的号码和密码,可以连接到MySQL数据库的Web代码[关闭]

sh7euo9m  于 10个月前  发布在  PHP
关注(0)|答案(1)|浏览(66)

已关闭。此问题需要更多focused。它目前不接受回答。
**希望改进此问题?**更新问题,使其仅针对editing this post的一个问题。

4天前关闭。
Improve this question
我只是想创建这个登录系统
解决我的问题解决我的问题

jslywgbw

jslywgbw1#

1.在MySQL中创建数据库。
1.在数据库中创建具有以下列的表:用户名、年龄、地址、移动的号码和密码。
1.编写一个PHP脚本,该脚本将连接到MySQL数据库并将数据插入表中。
1.编写一个HTML表单,允许用户输入用户名、年龄、地址、移动的号码和密码。
1.将HTML表单链接到PHP脚本。下面是一个PHP脚本示例,您可以使用它连接MySQL数据库并将数据插入表中:

<?php
// Connect to the MySQL database
$conn = mysqli_connect("localhost", "username", "password", "databasename");
// Check if the connection was successful
if ($conn) {
    // Insert data into the table
    $sql = "INSERT INTO users (username, age, address, mobile number, password) VALUES ('$_POST['username'], $_POST['age'], '$_POST['address'], '$_POST['mobile number'], '$_POST['password']');";
    // Execute the query
    mysqli_query($conn, $sql);
    // Close the connection
    mysqli_close($conn);
} else {
    // Display an error message
    echo "Error connecting to the database.";
}
?>

字符串
下面是一个HTML表单示例,您可以使用它来允许用户输入他们的用户名、年龄、地址、移动的号码和密码:

<form action="insert.php" method="post">
<input type="text" name="username" placeholder="Enter your username">
<input type="text" name="age" placeholder="Enter your age">
<input type="text" name="address" placeholder="Enter your address">
<input type="text" name="mobile number" placeholder="Enter your mobile number">
<input type="password" name="password" placeholder="Enter your password">
<input type="submit" value="Submit">
</form>


我希望这对你有用。

相关问题