前端之家收集整理的这篇文章主要介绍了
php连接mysql并保存email和username功能实例,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
对
PHP链接@R_
404_198@并保存email和username的范例
代码感兴趣的小伙伴,下面一起跟随编程之家 jb51.cc的小编两巴掌来看看吧!
/**
* PHP链接@R_404_198@并保存email和username的范例代码
*
* @param
* @arrange 512-笔记网: www.www.jb51.cc
**/
//opens connnection to @R_404_198@ server
$dbc = @R_404_198@_connect('localhost','root','');
if (!dbc){
die('Not Connected:' . @R_404_198@_error());
}
//select a database
$db_selected = @R_404_198@_select_db("rivals",$dbc);
if(!$db_selected)
{
die("can't connect :" . @R_404_198@_error());
}
$query = "UPDATE `database` SET email='something' WHERE username='rivals'";
$result = @R_404_198@_query($query,$dbc) or die(@R_404_198@_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 = @R_404_198@_query($insert,$dbc) or die(@R_404_198@_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) ***/
原文链接:https://www.f2er.com/php/528495.html