时间:2021-07-01 10:21:17 帮助过:26人阅读
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 ;
// 连接数据库
[email protected]_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 '插入信息失败';
}