本文整理汇总了PHP中BD::connect方法的典型用法代码示例。如果您正苦于以下问题:PHP BD::connect方法的具体用法?PHP BD::connect怎么用?PHP BD::connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BD
的用法示例。
在下文中一共展示了BD::connect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: session_start
<?php
/*
session_start();
if(!isset($_SESSION['user'])){
header('location: login.php');
exit("Need to login to the system touse this function.");
}
*/
define('DB_SERVER', 'localhost');
define('DB_NAME', 'sm');
define('DB_USER', 'root');
define('DB_PASS', '');
BD::connect();
class bd
{
public static $con;
public static function connect()
{
BD::$con = mysqli_connect(DB_SERVER, DB_USER, DB_PASS, DB_NAME);
if (!bd::$con) {
echo "Error: No se pudo conectar a MySQL." . PHP_EOL;
exit;
}
mysqli_set_charset(BD::$con, "utf8");
}
public static function cast_query_results($rs)
{
$fields = mysqli_fetch_fields($rs);
$data = array();
$types = array();
示例2: unset
function proverka_danux()
{
if (isset($_POST['fio'])) {
$this->fio = $_POST['fio'];
if ($this->fio == '') {
unset($this->fio);
}
}
if (isset($_POST['mail'])) {
$this->mail = $_POST['mail'];
if ($this->mail == '') {
unset($this->mail);
}
}
if (isset($_POST['login'])) {
$this->login = $_POST['login'];
if ($this->login == '') {
unset($this->login);
}
}
if (isset($_POST['pass'])) {
$this->pass = $_POST['pass'];
if ($this->pass == '') {
unset($this->pass);
}
}
if (isset($_POST['pass1'])) {
$this->pass1 = $_POST['pass1'];
if ($this->pass1 == '') {
unset($this->pass1);
}
}
if ($this->pass == $this->pass1) {
$this->pass2 = $this->pass;
} else {
exit("Пароли не совпадают, повторите попытку!");
}
if (empty($this->login) or empty($this->pass2) or empty($this->fio) or empty($this->mail)) {
exit("Вы ввели не всю информацию, пожалуйста заполните все поля!");
}
$this->login = stripslashes($this->login);
$this->login = htmlspecialchars($this->login);
$this->login = trim($this->login);
$this->mail = trim($this->mail);
if (!preg_match('/^([a-z0-9])(\\w|[.]|-|_)+([a-z0-9])@([a-z0-9])([a-z0-9.-]*)([a-z0-9])([.]{1})([a-z]{2,4})$/is', $_POST['mail'])) {
return false;
}
if (strlen($_POST['login']) < 5) {
return false;
}
// не меньше 4 символов логин
$this->pass2 = stripslashes($this->pass2);
$this->pass2 = htmlspecialchars($this->pass2);
$this->pass2 = trim($this->pass2);
if (strlen($_POST['pass']) < 5) {
return false;
}
//не меньше 5 символов пароль
$this->pass2 = password_hash($this->pass2, PASSWORD_BCRYPT);
$date_reg = date('Y:m:d H:i');
$pdo = new BD();
$pdo->connect();
$res = $pdo->query("SELECT `id`, `pass`, `login` FROM `users` WHERE 'login' = '{$this->login}'");
$row = $res->fetch();
if (!empty($row['id'])) {
exit("Данный пользователь уже зарегестирован!");
} else {
$res1 = mysql_query("INSERT INTO user (login,pass,mail,fio,date_reg) VALUE ('{$login}', '{$pass2}','{$mail}', '{$fio}', '{$date_reg}')");
}
}