这里是 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/