function obtenerDatosTabla() { $manejadorBD = new ManejadorMySql(); $manejadorBD->abrirConexion(); $rowsContent = ""; $resultadoConsulta = $manejadorBD->realizarConsulta("SELECT nombre, especialidad FROM documentos"); if ($resultadoConsulta) { while ($row = $resultadoConsulta->fetch_row()) { $rowsContent .= "<tr><td>" . $row[0] . "</td>"; $rowsContent .= "<td>" . $row[1] . "</td></tr>"; } } $manejadorBD->cerrarConexion(); return $rowsContent; }
function obtenerDatosTabla() { $manejadorBD = new ManejadorMySql(); $manejadorBD->abrirConexion(); $rowsContent = ""; $resultadoConsulta = $manejadorBD->realizarConsulta("SELECT nombre, especialidad FROM documentos"); if ($resultadoConsulta) { while ($row = $resultadoConsulta->fetch_row()) { $rowsContent .= "<tr><td>" . $row[0] . "</td>"; $rowsContent .= "<td>" . $row[1] . "</td>"; $rowsContent .= "<td class='text-center'><a href='baja-documentos-post.php' onclick='enviarDato(event, this, \"" . $row[0] . "\");'><img src='../img/eliminar.png'></a></tr>"; } } $manejadorBD->cerrarConexion(); return $rowsContent; }
function iniciarSesion($user, $pass) { $manejadorBD = new ManejadorMySql(); $manejadorBD->abrirConexion(); $resultadoConsulta = $manejadorBD->realizarConsulta("SELECT matricula FROM alumno " . "WHERE matricula='" . $user . "' and password= sha1('" . $pass . "')"); if (mysqli_num_rows($resultadoConsulta) > 0) { $_SESSION["alumno"] = true; } else { include_once "logout.php"; } $manejadorBD->cerrarConexion(); /*$arrayResult= array(); if($resultadoConsulta) while($row= mysqli_fetch_assoc($resultadoConsulta)) $arrayResult[]= $row; echo json_encode($arrayResult);*/ }
function obtenerDatosTabla() { $manejadorBD = new ManejadorMySql(); $manejadorBD->abrirConexion(); $rowsContent = ""; $resultadoConsulta = $manejadorBD->realizarConsulta("SELECT matricula, nombre, apellido, semestre, carrera, correo " . "FROM alumno"); if ($resultadoConsulta) { while ($row = $resultadoConsulta->fetch_row()) { $rowsContent .= "<tr><td>" . $row[0] . "</td>"; $rowsContent .= "<td>" . $row[1] . "</td>"; $rowsContent .= "<td>" . $row[2] . "</td>"; $rowsContent .= "<td>" . $row[3] . "</td>"; $rowsContent .= "<td>" . $row[4] . "</td>"; $rowsContent .= "<td>" . $row[5] . "</td></tr>"; } } $manejadorBD->cerrarConexion(); return $rowsContent; }
function obtenerDatosTabla() { $manejadorBD = new ManejadorMySql(); $manejadorBD->abrirConexion(); $rowsContent = ""; $resultadoConsulta = $manejadorBD->realizarConsulta("SELECT matricula, nombre, apellido, semestre, carrera, correo " . "FROM alumno"); if ($resultadoConsulta) { while ($row = $resultadoConsulta->fetch_row()) { $rowsContent .= "<tr><td>" . $row[0] . "</td>"; $rowsContent .= "<td>" . $row[1] . "</td>"; $rowsContent .= "<td>" . $row[2] . "</td>"; $rowsContent .= "<td>" . $row[3] . "</td>"; $rowsContent .= "<td>" . $row[4] . "</td>"; $rowsContent .= "<td>" . $row[5] . "</td>"; $rowsContent .= "<td class='text-center'><a href='baja-alumno-post.php' onclick='enviarDato(event, this, \"" . $row[0] . "\");'><img src='../img/eliminar.png'></a></tr>"; } } $manejadorBD->cerrarConexion(); return $rowsContent; }
<?php //implementar seguridad include_once "../php/ManejadorMySql.php"; $nombre = $_POST["nombre"]; //validar caracteres, evitar inyección $especialidad = $_POST["especialidad"]; //validar caracteres, evitar inyección $manejadorBD = new ManejadorMySql(); $manejadorBD->abrirConexion(); $resultadoConsulta = $manejadorBD->realizarConsulta("INSERT INTO documentos VALUES('" . $nombre . "', '" . $especialidad . "')"); if ($resultadoConsulta) { echo "Documento registrado"; } else { echo "No se puede registrar la documento"; } $manejadorBD->cerrarConexion();