Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername = "localhost";
- $username = "root";
- $password = "";
- $dbname = "test_db";
- try {
- $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
- $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- $stmt = $conn->prepare("INSERT INTO users (nickame, password)
- VALUES (:nickame, :password)");
- $stmt->bindParam(':nickame', $nickame);
- $stmt->bindParam(':password', $password);
- $nickame = "test3";
- $password = "test";
- $stmt->execute();
- echo "New record created successfully";
- }
- catch(PDOException $e)
- {
- echo "Error: " . $e->getMessage();
- }
- $conn = null;
- ?>
Add Comment
Please, Sign In to add comment