How to create a form for an existing mysql database [closed]

0

How can I create a form that stores information in a table in an existing mysql database?

    
asked by Jhonatan Meza 13.04.2018 в 20:25
source

1 answer

0

Since you do not offer a code base to show you the answer here I leave you a simple example:

<!DOCTYPE html>
<html>
<body>

<h2>HTML Forms</h2>

<form action="/controlador.php">
  Nombre:<br>
  <input type="text" name="nombre" value="Mickey">
  <br><br>
  <input type="submit" value="Submit">
</form> 
</body>
</html>

Page controlador.php

<?php

$conn = new mysqli($servername, $username, $password, $dbname);
$stmt = $conn->prepare("INSERT INTO nombres (primer_nombre) VALUES (?)");
$stmt->bind_param($nombre);

$nombre = $_GET['nombre'];
$stmt->execute();

$conn->close();
?>
    
answered by 13.04.2018 / 20:45
source