Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $host = 'localhost';
- $db = 'DB_SELECTION';
- $user = 'DB_USERNAME';
- $pass = 'DB_PASSWORD';
- $charset = 'utf8mb4';
- $dsn = "mysql:host=$host;dbname=$db;charset=$charset";
- try {
- $opt = [ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, PDO::ATTR_EMULATE_PREPARES => false, ];
- $conn = new PDO($dsn, $user, $pass, $opt);
- }
- catch(PDOException $e) {
- echo "Connection failed: " . $e->getMessage();
- }
- if (isset($_POST["btnreg"]))
- {
- $query = "INSERT INTO users (username, password, email, mobile, address) VALUES (:username, :password, :email, :mobile, :address)";
- $result = $connect->prepare($query);
- $result->bindParam(":username", $username);
- $result->bindParam(":password", $password);
- $result->bindParam(":email", $email);
- $result->bindParam(":mobile", $mobile);
- $result->bindParam(":address", $address);
- $username = $_POST["username"];
- $password = $_POST["password"];
- $email = $_POST["email"];
- $mobile = $_POST["mobile"];
- $address = $_POST["address"];
- if ($result->execute())
- {
- echo "Insert successfuly";
- } else {
- echo "Inser unsuccessfil";
- }
- } else {
- echo "Error, you did not submit the form properly"
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement