function buscar($busqueda) { $respuesta = new xajaxResponse(); $conn = new conexionBD(); $sql = "SELECT * FROM profesores WHERE Nombre LIKE '%{$busqueda}%'"; if (!$conn->EjecutarSQL($sql)) { $MSG = "Ha ocurrido un error al buscar en la base de datos.\nPor favor, intentelo nuevamente."; } $respuesta->addAlert("Buscando: " . $sql); return $respuesta; }
function guardar($formulario) { //comentaré todo lo que tenga que ver con la Base de Datos $flag = 0; extract($formulario); $respuesta = new xajaxResponse(); $conn = new conexionBD(); //Genera una nueva coneccion $conn->EjecutarSQL("BEGIN TRANSACTION A1"); if (!$conn->EjecutarSQL("BEGIN TRANSACTION A1")) { $MSG = "No se puede conectar a la base de datos"; } // al guardar los numeros de las lineas nos aseguramos que si borran una no perderemos las referencias. foreach ($hdnIdCampos as $id) { // Así recorro cada campo en cada linea // Guardo la consulta en una cadena (cambiado el nombre de la tabla de personas a profesores) $Str_SQL = "INSERT INTO profesores( `Nombre` , `Despacho`, `Telefono` , `Correo`, `Id_material`, `Foto`) \nVALUES (\n'" . utf8_encode($formulario['hdnNombre_' . $id]) . "', '" . $formulario['hdnDes_' . $id] . "' , '" . $formulario['hdnTelefono_' . $id] . "', '" . $formulario['hdnCorreo_' . $id] . "' ,'0','" . $formulario['hdnFoto_' . $id] . "' )"; if (!$conn->EjecutarSQL($Str_SQL)) { //CONTROL DE ERRORES. muy importante, si no guarda uno, no guarda nada. $conn->EjecutarSQL("ROLLBACK TRANSACTION A1"); $flag = 1; $MSG = "Ha ocurrido un error al insertar los datos de la persona.\nPor favor, intentelo nuevamente."; } //$respuesta->addAlert($Str_SQL); if ($flag == 0) { $conn->EjecutarSQL("COMMIT TRANSACTION A1"); $MSG = "Datos guardados con exito"; } // }else{ // echo "el profesor ya existe"; //} } //$copy = copy(, 'images/image.jpg'); $respuesta->addAlert($MSG); return $respuesta; }
function __construct() { parent::__construct(); }
function guardar($formulario, $profesor) { $flag = 0; extract($formulario); $respuesta = new xajaxResponse("utf-8"); $conn = new conexionBD(); //Genera una nueva conexion $conn->EjecutarSQL("SET NAMES 'utf8'"); // al guardar los numeros de las lineas nos aseguramos que si borran una no perderemos las referencias. foreach ($hdnIdCampos as $id) { $profesor = $formulario['hdnProfesor_' . $id]; $sqlpro = "SELECT * FROM `equipamiento_eii`.`profesores` WHERE Nombre = '" . limpiar($profesor) . "' "; $result = $conn->EjecutarSQL($sqlpro); $filas = mysql_num_rows($result); if ($filas == 0) { //CONTROL DE ERRORES. muy importante, si no guarda uno, no guarda nada. $conn->EjecutarSQL("ROLLBACK TRANSACTION A1"); $MSG = "El profesor seleccionado no existe.\nPor favor, intentelo nuevamente."; $respuesta->addAlert($MSG); return $respuesta; } $row = $conn->FetchArray($result); $monitor = str_replace('||', '"', $formulario['hdnMonitor_' . $id]); $Str_SQL = "INSERT INTO material(`Id_profesor`, `PC` , `Fecha_PC` , `Portatil` , `Fecha_Portatil` , `Monitor` , `Fecha_Monitor`, `Otros`, `Fecha_Otros` ) \n VALUES ('','" . $formulario['hdnPC_' . $id] . "', '" . fecha($formulario['hdnFechaPC_' . $id]) . "', '" . $formulario['hdnPortatil_' . $id] . "', '" . fecha($formulario['hdnFechaPortatil_' . $id]) . "',\n '" . $monitor . "',\n '" . fecha($formulario['hdnFechaMonitor_' . $id]) . "', '" . $formulario['hdnOtros_' . $id] . "', '" . fecha($formulario['hdnFechaOtros_' . $id]) . "')"; $Str_SQL2 = "INSERT INTO material(`Id_profesor`, `PC` , `Fecha_PC` , `Portatil` , `Fecha_Portatil` , `Monitor` , `Fecha_Monitor`, `Otros`, `Fecha_Otros` ) \n VALUES ('" . $row['Id'] . "','" . $formulario['hdnPC_' . $id] . "', '" . fecha($formulario['hdnFechaPC_' . $id]) . "', '" . $formulario['hdnPortatil_' . $id] . "', '" . fecha($formulario['hdnFechaPortatil_' . $id]) . "',\n '" . $monitor . "',\n '" . fecha($formulario['hdnFechaMonitor_' . $id]) . "', '" . $formulario['hdnOtros_' . $id] . "', '" . fecha($formulario['hdnFechaOtros_' . $id]) . "')"; if ($row['Id_material'] == '0') { if (!$conn->EjecutarSQL($Str_SQL)) { //CONTROL DE ERRORES. muy importante, si no guarda uno, no guarda nada. $conn->EjecutarSQL("ROLLBACK TRANSACTION A1"); $flag = 1; $MSG = "Ha ocurrido un error al insertar los datos de los materiales.\nPor favor, intentelo nuevamente."; } } else { if (!$conn->EjecutarSQL($Str_SQL2)) { //CONTROL DE ERRORES. muy importante, si no guarda uno, no guarda nada. $conn->EjecutarSQL("ROLLBACK TRANSACTION A1"); $flag = 1; $MSG = "Ha ocurrido un error al insertar los datos de los materiales.\nPor favor, intentelo nuevamente."; } } if ($flag == 0) { $lastid = mysql_insert_id(); $conn->EjecutarSQL("SET NAMES 'utf8'"); //$row = $conn->FetchArray($result); $sql = "UPDATE `equipamiento_eii`.`material` SET `Id_profesor` = '" . $row['Id'] . "' WHERE `material`.`Id` = '" . $lastid . "' "; if (!$conn->EjecutarSQL($sql)) { //CONTROL DE ERRORES. muy importante, si no guarda uno, no guarda nada. $conn->EjecutarSQL("ROLLBACK TRANSACTION A1"); $MSG = "Ha ocurrido un error al actualizar los materiales.\nPor favor, intentelo nuevamente."; } if ($row['Id_material'] == '0') { $conn->EjecutarSQL("SET NAMES 'utf8'"); $sql = "UPDATE `equipamiento_eii`.`profesores` SET `Id_material` = '" . $row['Id'] . "' WHERE `profesores`.`Id` = '" . $row['Id'] . "' "; if (!$conn->EjecutarSQL($sql)) { printf("ultimo registro insertado tiene el id %d\n", $lastid); } $conn->EjecutarSQL("COMMIT TRANSACTION A1"); } $MSG = "Datos guardados con exito"; } } $respuesta->addAlert($MSG); return $respuesta; }
if ($email9 != "") { $query = "SELECT email_address FROM elforodeltenis_members WHERE email_address = '{$email9}'"; $gt = new conexionBD(); $gt->doQuery("{$query}"); $email9_registrado = $gt->getNumRows(); } $gt->setClose(); $query = "SELECT email_amigo FROM elforodeltenis_recomendaciones WHERE id_member = '{$_GET['m']}' AND numero = '10'"; $gt = new conexionBD(); $gt->doQuery("{$query}"); while ($gt->setWhile()) { $email10 = $gt->getDataSQL("email_amigo"); } if ($email10 != "") { $query = "SELECT email_address FROM elforodeltenis_members WHERE email_address = '{$email10}'"; $gt = new conexionBD(); $gt->doQuery("{$query}"); $email10_registrado = $gt->getNumRows(); } $gt->setClose(); ?> <div class="row space-up"> <div class="col-md-3"><img src="http://www.elforodeltenis.com/Themes/BeCool_2/images/elforodeltenis.gif" alt="el foro del tenis"></div> <div class="col-md-6"></div> <div class="col-md-3"> <a href="http://www.elforodeltenis.com"> <h1>Volver al foro...</h1> </a> </div> </div> <div class="row space-up">
<?php $fecha = date("d/m/Y"); include "classes/class_general_db.php"; $query = "SELECT member_name, email_address FROM elforodeltenis_members WHERE id_member = '{$_GET['us']}'"; $po = new conexionBD(); $po->doQuery("{$query}"); while ($po->setWhile()) { $member_name = $po->getDataSQL("member_name"); $email_address = $po->getDataSQL("email_address"); } $po->setClose(); $query = "INSERT INTO elforodeltenis_descarga_powerplay ( id_usuario, fecha, version) VALUES ('{$_GET['us']}', '{$fecha}', '1')"; $po = new conexionBD(); $po->doQuery("{$query}"); include "classes/class.phpmailer.php"; //Envía email $mail = new PHPMailer(); $mail->Host = "localhost"; $mail->From = "*****@*****.**"; $mail->FromName = "Descarga Powerplay | Elforodeltenis.com"; $mail->Subject = "Nueva descarga de la revista N.1 de Powerplay"; $mail->AddAddress('dcolja@elforodeltenis.com; pacoalmendros@ono.com'); $body = "<strong>El usuario {$member_name} se acaba de descargar el número 1 de la revista Powerplay.<br><br>"; $body .= "<i>Mensaje enviado desde la web de elforodeltenis.com</i><br>"; $body .= "<a href=\"http://www.elforodeltenis.com\"><img src=\"http://www.elforodeltenis.com/Themes/BeCool_2/images/elforodeltenis.gif\"></a>"; $mail->Body = $body; $mail->IsHTML(true); $mail->Send(); $mail = new PHPMailer(); $mail->Host = "localhost";
Telefono: <input type="text" name="tele"><br> <br><input type="Submit" name="ok" value="Registrar"> </form> <form action="inicio.html"> <input type="Submit" name="atras" value="Atras"> </form> <?php } else { if ($opcion == 2) { ?> <p align="center"> Lista de Contactos <br><hr> <?php require_once 'conexion.php'; $db = new conexionBD(); $db->conectar(); $registros = mysql_query("select * from datos"); while ($reg = mysql_fetch_array($registros)) { echo "ID: " . $reg['id'] . "<br>"; echo "Nombre: " . $reg['nombre'] . "<br>"; echo "Telefono: " . $reg['telefono'] . "<br>"; echo "<br>"; echo "<hr>"; } $db->cerrar(); ?> </p> <form action="inicio.html"> <input type="Submit" name="atras" value="Atras"> </form>
<table> <?php include "classes/class_general_db.php"; $query = "SELECT id_usuario FROM elforodeltenis_descarga_powerplay WHERE id_usuario<>'' group by id_usuario"; $po = new conexionBD(); $po->doQuery("{$query}"); while ($po->setWhile()) { $id_usuario = $po->getDataSQL("id_usuario"); $query = "SELECT email_address, member_name FROM elforodeltenis_members WHERE id_member = '{$id_usuario}'"; $op = new conexionBD(); $op->doQuery("{$query}"); while ($op->setWhile()) { $email_address = $op->getDataSQL("email_address"); $member_name = $op->getDataSQL("member_name"); ?> <tr> <td><?php echo $email_address; ?> </td> <td><?php echo $member_name; ?> </td> </tr> <?php } } ?> </table>
<html> <title>Modificar</title> <body> <?php require_once 'conexion.php'; $db = new conexionBD(); $db->conectar(); $id = $_POST['id']; echo "Datos Anteriores" . "<br>" . "<br>"; $registro = mysql_query("select * from datos where id={$id}"); if ($reg = mysql_fetch_array($registro)) { echo "Nombre: " . $reg['nombre'] . "<br>"; echo "Telefono: " . $reg['telefono'] . "<br>"; echo "<hr>"; ?> <form method="post" action="modificar2.php"> Nuevos datos<br><br> Nombre: <input type="text" name="nombre"><br> Telefono: <input type="text" name="telefono"> <input type="hidden" name="id" value=<?php echo $reg['id']; ?> > <br><br> <input type="Submit" name="modi" value="modificar"> </form> <form action="inicio.html" align="center"> <input type="Submit" value="Inicio"> </form>
<?php if (isset($_POST['contacto']) && $_POST['contacto'] == "contacto") { include "classes/class_general_db.php"; $query = "SELECT member_name FROM elforodeltenis_members WHERE email_address = '{$_POST['email']}'"; $po = new conexionBD(); $po->doQuery("{$query}"); $existe = $po->getNumRows(); if ($existe < 1) { $es_usuario = "NO"; } if ($existe > 0) { while ($po->setWhile()) { $member_name = $po->getDataSQL("member_name"); } $es_usuario = "SI -> {$member_name}"; } include "classes/class.phpmailer.php"; //Envía email $mail = new PHPMailer(); $mail->Host = "localhost"; $mail->From = "{$_POST['email']}"; $mail->FromName = "{$_POST['nombre']} | Contacto - Elforodeltenis.com"; $mail->Subject = "{$_POST['asunto']}"; $mail->AddAddress('*****@*****.**'); $body = "<strong>Contexto del mensaje: {$_POST['destino']}</strong><br><br>Asunto: {$_POST['asunto']}<br>Nombre: {$_POST['nombre']}<br>Email: {$_POST['email']}<br>Es usuario: {$es_usuario}<br><br>Mensaje: {$_POST['mensaje']}<br><br>"; $body .= "<i>Mensaje enviado desde la web de elforodeltenis.com</i>"; $mail->Body = $body; $mail->IsHTML(true); $mail->Send(); $mail = new PHPMailer();