Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $host = "localhost";
- $dbname = "scotchbox";
- $user = "root";
- $pass = "root";
- try {
- // Abre a conexão com o DB
- $conn = new PDO("mysql:host = $host; dbname = $dbname", $user, $pass);
- $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- // Faz a operação de INSERT no DB
- $stmt = $conn->prepare("INSERT INTO usuarios (nome, idade) VALUES (:nome, :idade)");
- $stmt = bindParam(":nome", $_POST["nome"]);
- $stmt = bindParam(":idade", $_POST["idade"]);
- $stmt->execute();
- echo "Valores inseridos com sucesso!";
- } catch {
- echo "ERRO: " . $e->getMessage();
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement