You are on page 1of 14

<!

DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>formulario</title>
<meta name="viewport" content="width=device-width, initial-
scale=1, shrink-to-fit=no">
<link rel= "stylesheet" href= "css/bootstrap.css" >
<link rel= "stylesheet" href= "css/font-
awesome.css" >
<link rel= "stylesheet" href= "css/all.css" >
<link rel= "stylesheet" href= "css/mdb.css" >

</head>
<body>
<br>
<br>
<br>
<br>
<div class= "row" >
<div class= "col-3" ></div>
<div class= "col-6" >

<form action= "prueba/datos.php" method= "post"class= "


border border-light pt-5" >

<label for= "" >Nombre</label>


<input type= "text" name= "nombre" class=
"form-control
<label for= "" >Cantidad</label>
<input type= "text" name= "cantidad" class=
"form-control" >
<label for= "" >Precio</label>
<input type= "text" name= "precio" class=
"form-control" >

<button class= "btn btn-outline-black btn-rounded "


type= "submit" >Enviar</button>
</form>
</div>

</div>

<script src= "js/jquery-3.3.1.min.js" ></script>


<script src= "js/bootstrap.min.js" ></script>
<script src= "js/popper.min.js" ></script>
<script src= "js/mdb.min.js" ></script>

</body>
</html>

<?php
$host= "localhost" ;
$user= "root" ;
$pwd= "" ;
$db= "redsocial" ;

$mysqli = new mysqli ($host,$user,$pwd,$db);

if ( $mysqli ->connect_errno) {
echo "Falló la conexión a la Base de Datos";
}

mysqli_set_charset($mysqli, "utf8mb4" ); //para que la


conexión entregue los acentos

return $mysqli;
?>

<?php

require_once('../lib/conexion.php');

$nombre = $_POST['nombre'];
$cant = $_POST['cantidad'];
$precio = $_POST['precio'];
echo 'por '.$cant.' '.$nombre.' tiene que pagar : '.
($precio*$cant);

header("Refresh:5; url=../formulario.php");

?>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>formulario</title>
<meta name="viewport" content="width=device-width, initial-
scale=1, shrink-to-fit=no">
<link rel= "stylesheet" href= "css/bootstrap.css" >
<link rel= "stylesheet" href= "css/font-
awesome.css" >
<link rel= "stylesheet" href= "css/all.css" >
<link rel= "stylesheet" href= "css/mdb.css" >

</head>
<body>
<br>
<br>
<br>
<br>
<div class= "row" >
<div class= "col-3" ></div>
<div class= "col-6" >

<form id="formulario2" action="" method= "post"class=


" border border-light pt-5" >

<label for= "" >Nombre</label>


<input type= "text" name= "nombre" class=
"form-control
<label for= "" >Cantidad</label>
<input type= "text" name= "cantidad" class=
"form-control" >
<label for= "" >Precio</label>
<input type= "text" name= "precio" class=
"form-control" >

<button id= "enviar" class= "btn btn-outline-black


btn-rounded " type= "submit" >Enviar</button>
</form>
<div class= "respuesta" ></div>
</div>

</div>

<script src= "js/jquery-3.3.1.min.js" ></script>


<script src= "js/bootstrap.min.js" ></script>
<script src= "js/popper.min.js" ></script>
<script src= "js/mdb.min.js" ></script>

<script>
$(document).ready(function(){
$('#enviar').on("click", function(e){
e.preventDefault(); //evita que la página se
actualise
var frm = $('#formulario2').serialize();
//conpactar todos los datos a una sola variable
$.ajax({
type:'POST',
url:'prueba/datos.php',
data: frm,
success:function(resp){
$('.respuesta').html(resp);
}
});
});
});
</script>
</body>
</html>

<?php
$host= "localhost" ;
$user= "root" ;
$pwd= "" ;
$db= "productos" ;

$mysqli = new mysqli ($host,$user,$pwd,$db);

if ( $mysqli ->connect_errno) {
echo "Falló la conexión a la Base de Datos";
}

mysqli_set_charset($mysqli, "utf8mb4" ); //para que la


conexión entregue los acentos

return $mysqli;
?>

<?php

require_once('../lib/conexion2.php');

$nombre = $_POST['nombre'];
$cant = $_POST['cantidad'];
$precio = $_POST['precio'];

$sent = "INSERT INTO


producto(nom_prod,cant_prod,precio_prod) VALUES
('$nombre','$cant','$precio')";

$resp = $mysqli->query($sent);
if ($resp){
echo "los datos se guardaron correctamente";
}else{
echo "no se guardaron los datos";
}

?>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>formulario</title>
<meta name="viewport" content="width=device-width, initial-
scale=1, shrink-to-fit=no">
<link rel= "stylesheet" href= "css/bootstrap.css" >
<link rel= "stylesheet" href= "css/font-
awesome.css" >
<link rel= "stylesheet" href= "css/all.css" >
<link rel= "stylesheet" href= "css/mdb.css" >

</head>
<body>
<br>
<br>
<br>
<br>
<div class= "row" >
<div class= "col-3" ></div>

div class= "col-6" >


<form id="formulario3" action="" method= "post"class= "
border border-light pt-5" style=" background:url
(http://data.whicdn.com/images/182448298/large.png);" >
<font class= " text-center py-4 bounceOut" style=" color:
#e91e63;" face= " Comic Sans MS,arial,verdana" size= "09">
<center>Formulario</center>

<div class= "col" >


<label for= "" >Nombre</label>
<input type= "text" name= "nombre" class=
"form-control >
</div>

<div class= " col " >


<label for= "" >Apellido</label>
<input type= "text" name= "ape" class= "form-
control" >
</div>

<div class= " col " >


<label for= "" >Dirección</label>
<input type= "text" name= "direc" class=
"form-control" >
</div>
<div class= " col " >
<label for= "" >Edad</label>
<input type= "text" name= "edad" class=
"form-control" >
</div>

<div class= " col " >


<label for= "" >Email</label>
<input type= "text" name= "email" class=
"form-control" >
</div>

<center><button id= "enviar" class= "btn btn-


outline-pink btn-rounded " type= "submit"
>Enviar</button></center>
</form>
<div class= "respuesta" ></div>
</div>

</div>

<script src= "js/jquery-3.3.1.min.js" ></script>


<script src= "js/bootstrap.min.js" ></script>
<script src= "js/popper.min.js" ></script>

<script src= "js/mdb.min.js" ></script>


<script>
$(document).ready(function(){
$('#enviar').on("click", function(e){
e.preventDefault(); //evita que la página se
actualise
var frm = $('#formulario3').serialize();
//conpactar todos los datos a una sola variable
$.ajax({
type:'POST',
url:'prueba/datos2.php',
data: frm,
success:function(resp){
$('.respuesta').html(resp);
}
});
});
});
</script>
</body>
</html>
<?php
$host= "localhost" ;
$user= "root" ;
$pwd= "" ;
$db= "usuario";

$mysqli = new mysqli ($host,$user,$pwd,$db);

if ( $mysqli ->connect_errno) {
echo "Falló la conexión a la Base de Datos";
}

mysqli_set_charset($mysqli, "utf8mb4" ); //para que la


conexión entregue los acentos

return $mysqli;
?>

<?php
require_once('../lib/conexion3.php');

$nombre = $_POST['nombre'];
$ape = $_POST['ape'];
$direc = $_POST['direc'];
$edad = $_POST['edad'];
$email = $_POST['email'];

$sent = "INSERT INTO usuario


(nom_us,ape_us,dir_us,edad_us,email_us) VALUES
('$nombre','$ape','$direc','$edad','$email')";

$resp = $mysqli->query($sent);
if ($resp){
echo "los datos se guardaron correctamente";
}else{
echo "no se guardaron los datos";
}

?>

You might also like