<?php
$conexion= new mysqli ("localhost", "id12035304_aks4", "*Contraseña escribo aca por obvios motivos*", "id12035304_planillas"); //ESTA ES LA LINEA DE CONEXIÓN
if($conexion->errno){
echo "fallo en la conexión" . $conexion->connect_errno;
}
$conexion->set_charset("utf8");
class envio{
var $nombre;
var $fecha;
var $elementoa;
var $elementob;
var $elementoc;
var $elementod;
var $elementoe;
var $lote;
function __construct(){
$this->fecha=$_POST["fecha"];
$this->lote=$_POST["lote"];
}
function set_prop($primero, $segundo, $tercero, $cuarto, $quinto, $nombre){
$this->elementoa=$primero;
$this->elementob=$segundo;
$this->elementoc=$tercero;
$this->elementod=$cuarto;
$this->elementoe=$quinto;
$this->nombre=$nombre;
if($this->elementoa == ""){
$this->elementoa=0;
}
if($this->elementob == ""){
$this->elementob=0;
}
if($this->elementoc == ""){
$this->elementoc=0;
}
if($this->elementod == ""){
$this->elementod=0;
}
if($this->elementoe == ""){
$this->elementoe=0;
}
}
function enviar($elementoa, $elementob, $elementoc, $elementod ,$elementoe, $conexion,$lote, $fecha, $nombre){
$insertar="INSERT INTO DATOS(FECHA, LOTE, NOMBRE, ELEMENTO1, ELEMENTO2, ELEMENTO3, ELEMENTO4, ELEMENTO5, SUMA) VALUES('$fecha', '$lote', '$nombre', $elementoa, $elementob, $elementoc,$elementod,$elementoe, $elementoa+$elementob+$elementoc+$elementod+$elementoe)";
$conexion->query($insertar);
if($conexion->errno){
echo $conexion->connect_errno . "<br>";
}
}
}
if(isset($_POST["listo"])){
$fila1= new envio();
$fila1->set_prop($_POST["elemento1"],$_POST["elemento2"],$_POST["elemento3"],$_POST["elemento4"],$_POST["elemento5"],$_POST["nombre"]);
$fila1->enviar($fila1->elementoa,$fila1->elementob,$fila1->elementoc,$fila1->elementod,$fila1->elementoe, $conexion, $fila1->lote, $fila1->fecha, $fila1->nombre);
$fila2= new envio();
$fila2->set_prop($_POST["elemento6"],$_POST["elemento7"],$_POST["elemento8"],$_POST["elemento9"],$_POST["elemento10"],$_POST["nombre2"]);
$fila2->enviar($fila2->elementoa,$fila2->elementob,$fila2->elementoc,$fila2->elementod,$fila2->elementoe, $conexion, $fila2->lote, $fila2->fecha, $fila2->nombre);
$fila3= new envio();
$fila3->set_prop($_POST["elemento11"],$_POST["elemento12"],$_POST["elemento13"],$_POST["elemento14"],$_POST["elemento15"],$_POST["nombre3"]);
$fila3->enviar($fila3->elementoa,$fila3->elementob,$fila3->elementoc,$fila3->elementod,$fila3->elementoe, $conexion, $fila3->lote, $fila3->fecha, $fila3->nombre);
$fila4= new envio();
$fila4->set_prop($_POST["elemento16"],$_POST["elemento17"],$_POST["elemento18"],$_POST["elemento19"],$_POST["elemento20"],$_POST["nombre4"]);
$fila4->enviar($fila4->elementoa,$fila4->elementob,$fila4->elementoc,$fila4->elementod,$fila4->elementoe, $conexion, $fila4->lote, $fila4->fecha, $fila4->nombre);
}
?>