Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- ini_set('display_errors', '1');
- error_reporting(E_ALL);
- class Db {
- private $host;
- private $db;
- private $user;
- private $pass;
- private $charset;
- public function __construct()
- {
- $this->host = 'localhost';
- $this->db = 'exam';
- $this->user = 'root';
- $this->pass = 'root';
- $this-> charset = 'utf8';
- }
- public function dbConnect()
- {
- $dsn = "mysql:host=$this->host;dbname=$this->db;charset=$this->charset";
- $opt = [
- PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
- PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
- PDO::ATTR_EMULATE_PREPARES => false,
- ];
- $this->pdo = new PDO($dsn, $this->user, $this->pass, $opt);
- }
- public function insert()
- {
- $stmt = $this->pdo->prepare('INSERT INTO request SET mail = :mail, telephone = :telephone,fio_user = :fio_user, message=:message');
- $result = $stmt->execute(array('mail'=>$_POST['mail'],'telephone'=>$_POST['telephone'],'fio_user'=>$_POST['fio_user'], 'message'=>$_POST['message']));
- return $result;
- }
- }
- ?>
Add Comment
Please, Sign In to add comment