I'm starting to use mysql and Php but my PHP file is blank

0

When sending my form via php the page is blank and does not show the text outside the php, here I leave the code

HTML:

<html>    
<head> 
<meta name ="viewport" content="width=device-width, initial-scale=1.0">
<title>Guardar datos en una base de datos</title>    
</head>    
<body>
<form method="post" action="registra.php">
    <p>Nombre:
        <input type="text" name="nombre" size="20" placeholder="Introduce tu nombre" >
    </p>    
    <p>E-mail:
        <input type="text" name="email" size="20" placeholder="email" >
    </p>    
    <p>
        <input type="submit" value="Guardar datos" name="B1" >
    </p>    
</form>    
</body>    
</html> 

Registra.php:

<!DOCTYPE html>
<html>
<head>
<title>Datos guardados</title>
<meta name ="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>

<?php
$nombre = $_POST['nombre'];
$email = $_POST['email'];
$fecha = date('Y-m-d');

include('abre_conexion.php');
$_GRABAR_SQL ="INSERT INTO $tabla_db1 (nombre,email,fecha) VALUES ('$nombre','$email','$fecha')";
mysql_query($_GRABAR_SQL);
include("cierra_conexion.php");
echo "<p>Datos guardados</p><p><a href='javascript:history.go(-1)'>VOLVER ATRÁS</a></p>";
?>
<br><p>guardado</p>
</body>
</html>

Abre_conexion.php:
<?php
$hotsdb = "localhost";
$basededatos = "id5879099_prueba1";
$usuariodb = "id5879099_oliver977";
$clavedb = "mnbvcxz99";
$tabla_db1 = "Usuarios";

$conexion_db = mysql_connect("$hotsdb","$usuariodb","$clavedb")
    or die ("error");
    $db = mysql_connect_db("$basededatos",$conexion_db)
    or die ("La Base de datos <b>$basededatos</b> no existe");
?>
    
asked by Oliver Eduardo López Arenas 02.07.2018 в 18:57
source

1 answer

0

This would be the right way to ingest data, although I do not know how mysql works, I recommend using mysqli

$query="INSERT INTO $tabla_db1(nombre,email,fecha)VALUES("$nombre","$email","$fecha")";
    
answered by 02.07.2018 / 19:12
source