Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- xmlhttp=new XMLHttpRequest();
- <form id="formulario" action="" method="POST">
- <div class="form-group">
- <label for="idnombre">Nombre:</label>
- <input type="text" class="form-control" id="idnombre" name="namenombre" placeholder="Ingresar Nombre">
- </div>
- <div class="form-group">
- <label for="idapellido">Apellido:</label>
- <input type="text" class="form-control" id="idapellido" name="nameapellido" placeholder="Ingresar Apellido">
- </div>
- <div class="form-group">
- <label for="idedad">Edad:</label>
- <input type="text" class="form-control" id="idedad" name="nameedad" placeholder="Ingresar Edad">
- </div>
- <button type="submit" id="button" class="btn btn-default">Registrar</button>
- </form>
- <?php
- $servername = "localhost";
- $username = "username";
- $password = "";
- $dbname = "demo";
- // Create connection
- $conn = new mysqli($servername, $username, $password, $dbname);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- $nombre = $_POST['namenombre'];
- $apellido = $_POST['nameapellido'];
- $edad = $_POST['nameedad'];
- $sql = "INSERT INTO persona (nombre, apellido, edad) VALUES ('$nombre', '$apellido', '$edad')";
- if ($conn->query($sql) === TRUE) {
- echo "New record created successfully";
- } else {
- echo "Error: " . $sql . "<br>" . $conn->error;
- }
- $conn->close();
- ?>
- <div class="alert alert-success">
- <a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
- <strong>Success!</strong> This alert box could indicate a successful or positive action.
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement