I have a small problem with a database ... I am making a form to register the records but at the moment of clicking the button summit tells me that the record was discharged but nothing is recorded in my database. The table I work on has a federated table connection on my localhost, I do not know if that has anything to do with it.
Document of registration .html
<body>
<div id=alta>
<center><form name='registro' method="POST" action="altas.php">
<p>Dirección IP:
<input type="text" name='Direccion ip' onChange="javascript:while("+this.value.charAt(0)==' ')this.value=this.value.substring(1,this.value.len ght);""><br>
</p>
<p>Máscara de Subred:
<input type="text" name='Mascara de subred' onChange="javascript:while("+this.value.charAt(0)==' ')this.value=this.value.substring(1,this.value.len ght);""><br>
</p>
<p>Ocupado por:
<input type="text" name='Ocupado por' onChange="javascript:while("+this.value.charAt(0)==' ')this.value=this.value.substring(1,this.value.len ght);""><br>
</p>
<p>Nodo:
<input type="number" name='Nodo' onChange="javascript:while("+this.value.charAt(0)==' ')this.value=this.value.substring(1,this.value.len ght);""><br>
</p>
<p>Switch/Panel: <select type="text" name:"Switch o panel" value="" onChange="javascript:while("+this.value.charAt(0)==' ')this.value=this.value.substring(1,this.value.len ght);"">
<option value="Switch">Switch</option>
<option value="Panel">Panel</option>
</option>
</select>
</p>
<p>Departamento: <select type="number" name:"iddpto" value="" onChange="javascript:while("+this.value.charAt(0)==' ')this.value=this.value.substring(1,this.value.len ght);"">
<option value="1">Administracion y Finanzas</option>
<option value="2">Asuntos Juridicos</option>
<option value="3">Comercial</option>
<option value="4">Ingenieria de Servicio al Cliente</option>
<option value="5">Mantenimiento</option>
<option value="6">Operación</option>
<option value="7">Planeación y Construcción </option>
<option value="8">Recursos Humanos</option>
<option value="9">Superintendencia </option>
<option value="10">Tecnologías de Información y Comunicacione</option>
</select>
</p>
<input type='submit' id='boton' value='Registrar'>
<input type='reset' id='boton' value='Limpiar'>
</form></center>
</div>
</body>
* This part marks the error in .php of Undefined Index for the fields of
Switch or Department in the document of altos.php that later I put
Connection code to bd I have it as library2.php
<?php
function conectar_bd($query)
{
$DB_SERVER = "miservidor";
$DB_USER = "miusuario";
$DB_DATABASE = "midb";
$DB_TABLE = "mitabla";
$DB_PWD = "micotraseña";
$conn=mysqli_connect($DB_SERVER, $DB_USER,$DB_PWD,$DB_DATABASE);
/* check connection */
if (mysqli_connect_errno())
{
printf("Connect failed: %s\n" , mysqli_connect_error());
exit();
}
if ($result=mysqli_query($conn,$query))
echo mysqli_connect_error();
return $result;
}
?>
Code of order of registration in table with name altos.php
<?php
$Direccion_ip=$Direccion_ip;
$Mascara_de_subred=$Mascara_de_subred;
$Ocupado_por=$Ocupado_por;
$Nodo=$Nodo;
$Switch_o_panel=$Switch_o_panel;
$idDpto=$idDpto;
include('libreria2.php');
$insert = "NSERT INTO 'dbIPs'.'ips' ('Direccion ip', 'Mascara de subred',
'Ocupado por', 'Nodo', 'Switch o panel', 'idDpto') VALUES ('$Direccion_ip',
'$Mascara_de_subred', '$Ocupado_por', '$Nodo', '$Switch_o_panel',
'$idDpto');";
conectar_bd($insert);
if (mysqli_connect_errno())
{
printf("Connect failed: %s\n" , mysqli_connect_error());
exit();
}
else
{
echo "<br>Dirección IP dada de alta corectamente<br>";
}
?>
Data types within my table
CREATE TABLE 'ips' (
'Direccion ip' VARCHAR(20) NOT NULL,
'Mascara de subred' VARCHAR(45) NOT NULL,
'Ocupada por' VARCHAR(45) NOT NULL,
'Nodo' INT(11) NOT NULL,
'Switch o panel' VARCHAR(25) NOT NULL,
'idDpto' VARCHAR(45) NOT NULL,
PRIMARY KEY ('Direccion ip'),
UNIQUE INDEX 'Direccion ip_UNIQUE' ('Direccion ip' ASC),
UNIQUE INDEX 'Nodo_UNIQUE' ('Nodo' ASC));