php连接mysql并保存email和username功能实例

前端之家收集整理的这篇文章主要介绍了php连接mysql并保存email和username功能实例前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
PHP链接MysqL并保存email和username的范例代码感兴趣的小伙伴,下面一起跟随编程之家 jb51.cc的小编两巴掌来看看吧!

/**
 * PHP链接MysqL并保存email和username的范例代码
 *
 * @param 
 * @arrange 512-笔记网: www.www.jb51.cc
 **/
 //opens connnection to MysqL server
$dbc = MysqL_connect('localhost','root','');
if (!dbc){
	die('Not Connected:' . MysqL_error());
	}
//select a database
$db_selected = MysqL_select_db("rivals",$dbc);
if(!$db_selected)
{
	die("can't connect :" . MysqL_error());
}
$query = "UPDATE `database` SET email='something' WHERE username='rivals'";
$result = MysqL_query($query,$dbc) or die(MysqL_error());
$username = $_GET['username'];
$email = $_GET['email'];
$password = $_GET['password'];
$insert = "INSERT INTO `database` (`username`,`email`,`password`) VALUES ('$username','$email','$password')";
if(isset($username) && isset($email) && isset($password)){
$addnew = MysqL_query($insert,$dbc) or die(MysqL_error());
}
if($addnew){
echo "Username [".$username."] with Email Address [".$email."] and password[".$password."]<br><br>";
}
// just a message
echo "it's done"

/***   来自编程之家 jb51.cc(jb51.cc)   ***/

猜你在找的PHP相关文章