时间:2021-07-01 10:21:17 帮助过:2人阅读
$username = $_GET['username'];
获取值之后就知道怎么做了吧。
$username = $_GET['username'];
获取值之后就知道怎么做了吧。
请贴出你的表结构。
请贴出你的表结构。
CREATE TABLE `unsubscribe` ( `id` int(10) unsigned NOT NULL auto_increment, `username` varchar(100) NOT NULL, PRIMARY KEY (`id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
// 连接数据库 $conn=@mysql_connect("localhost","root","123456") or die(mysql_error()); // localhost是添你db的host,如果不是本地的请修改这里@mysql_select_db('mydatabase',$conn) or die(mysql_error()); $username = isset($_GET['username'])? mysql_escape_string($_GET['username']) : '';if($username){ $sqlstr = "insert into unsubscribe(username) values('".$username."')"; mysql_query($sqlstr) or die(mysql_error()); echo 'insert success';}
$username=$_GET['username'];$con=mysqli_connect('localhost','root','123456','mydatabase');$sql="insert into unsubscribe(username) values('$username')";if(mysqli_query($con,$sql)){ echo '插入信息成功';}else{ echo '插入信息失败';}
CREATE TABLE `unsubscribe` ( `id` int(10) unsigned NOT NULL auto_increment, `username` varchar(100) NOT NULL, PRIMARY KEY (`id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
// 连接数据库 $conn=@mysql_connect("localhost","root","123456") or die(mysql_error()); // localhost是添你db的host,如果不是本地的请修改这里@mysql_select_db('mydatabase',$conn) or die(mysql_error()); $username = isset($_GET['username'])? mysql_escape_string($_GET['username']) : '';if($username){ $sqlstr = "insert into unsubscribe(username) values('".$username."')"; mysql_query($sqlstr) or die(mysql_error()); echo 'insert success';}
$username=$_GET['username'];$con=mysqli_connect('localhost','root','123456','mydatabase');$sql="insert into unsubscribe(username) values('$username')";if(mysqli_query($con,$sql)){ echo '插入信息成功';}else{ echo '插入信息失败';}
php在脚本运行结束后会自动关闭连接,不过还是建议手动关闭连接.
?????
mysql_close() or die('mysql close error');