gpt4 book ai didi

php - 如何通过url向mysql中添加数据

转载 作者:行者123 更新时间:2023-11-29 03:51:44 24 4
gpt4 key购买 nike

这里是 php 的新手,基本上我想知道如何使用 url 手动将数据添加到我的 mysql 表。

例如,假设我有一个名为用户的表,其中有 3 个字段,分别称为“ID”、“用户名”和“密码”。我希望像这样向表中添加数据:

http://localhost/register.php?id=1@username=bob@password=123@act=register (我不确定这是否完全正确)但是是的。

任何有关如何执行此操作的帮助将不胜感激!

最佳答案

mysql_connect('localhost', 'mysql_user', 'mysql_password');

mysql_select_db('database');

mysql_query("INSERT INTO table (id, username, password) VALUES ('".mysql_real_escape_string($_GET['id'])."', '".mysql_real_escape_string($_GET['username'])."', '".mysql_real_escape_string($_GET['password'])."')");

关于php - 如何通过url向mysql中添加数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5752107/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com