登录界面的MYSQL增删改查

登入界面的增删改查

<?php

$conn=mysql_connect("localhost","root","");

if(!$conn){

echo "连接失败";

}

$sql="use test";

mysql_query($sql,$conn);

$sql="set names utf8";

mysql_query($sql,$conn);

$pwd=md5("123");

$time=date("Y-m-d H:i:s");

//添加

/*$sql="insert into deng (name,pwd,time) values ('你我','$pwd','$time')";

$set=mysql_query($sql,$conn);

if($set==1){

echo "添加成功";

}else{

echo "添加失败";

}*/

//删除

/*$sql="delete from deng where id=2";

$set=mysql_query($sql,$conn);

if($set==1){

echo "删除成功";

}else {

echo "删除失败";

}*/

//修改

/*$sql="update deng set name='胡志明' where id=3";

$set=mysql_query($sql,$conn);

if($set==1){

echo "修改成功";

}else{

echo "修改失败";

}*/

//查询

$sql="select pwd from deng where name='我'";

$set=mysql_query($sql,$conn);

$result=mysql_fetch_array($set);

//print_r($result);

echo $result['pwd'];

if($set==1){

echo "查询成功";

}


你可能感兴趣的:(登录界面的MYSQL增删改查)