Foros del Web » Programando para Internet » PHP »

PHP OO Enviar Funciones en php

Estas en el tema de Enviar Funciones en php en el foro de PHP en Foros del Web. Buenas Espero que me puedan ayudar Necesito que a la hora que se se ejecute el archivo gurdar1.php tambien poder incluir el archivo de funciones.php ...
  #1 (permalink)  
Antiguo 20/04/2016, 09:01
 
Fecha de Ingreso: noviembre-2015
Mensajes: 21
Antigüedad: 8 años, 5 meses
Puntos: 0
Enviar Funciones en php

Buenas Espero que me puedan ayudar
Necesito que a la hora que se se ejecute el archivo gurdar1.php tambien poder incluir el archivo de funciones.php para que pueda enviar una email cada vez que guardan

Código PHP:
/***** funciones.php   ***\
<?php    
function enviar_mensaje(){
   global 
$database,$db;
   
$sql_vencen="select * from perdida where fech='2016-04-18'";  
   
$res_vencen=mysql_query($sql_vencen);
    
$flag=1;
    
$cuerpo="<table><tr><td>Registradas</td></tr><tr><td>:</td></tr></table>";
    
$cuerpo.=    "<table width='100%' border='0' cellspadding='0' bordercolor='#677991' bgcolor='#3399FF'>
                    <tr bgcolor='#3399FF'>
            <th>Item</th>
                        <th>Cod</th>
                        <th>Nombre</th>
                        <th>Registro</th>                        
                        <th>Fecha Expediente</th>
             <th>Fecha Registro</th>
                        <th>Tipo</th>
                    <tr>"
;
    while(
$row=mysql_fetch_array($res_vencen)){
        
$cuerpo.="<tr bgcolor='#FFFFFF'>
                    <td><div align='center'>"
.$flag."</div></td>
                    <td><div align='center'>"
.$row['cod']."</div></td>
                    <td><div align='center'><"
.$row['reg']."</div></td>
                    <td><div align='center'>"
.$row['fecha']."</div></td>
        <td><div align='center'>"
.$row['fech']."</div></td>
                    <td><div align='center'>"
.$row['tipperdia']."</div></td>";                       
        
$flag++;
    }
    
    
    
$nombres="Soporte";
    
$correo="[email protected]";

    
$mail = new PHPMailer();
    
$mail->IsSMTP();               
    
$mail->Host     ""
    
$mail->SMTPAuth false;       
    
$mail->Username 'aguzman'
    
$mail->Password =  'ehjguzman';

    if (!
$mail->SetLanguage('es','includes/correo/language/'))
    {
        echo 
'<p>No se ha podido cargar el fichero de idioma adecuado.</p>';
    }

    
$mail->From     "$correo";
    
$mail->FromName "$nombres";


    
$mail->AddAddress("[email protected]");
    
$mail->AddAddress("[email protected]");

    
$mail->WordWrap 50
    
$mail->IsHTML(true); 

    
$mail->Subject  =  "ALERTA REGISTRO";
    
$mail->Body     =   $cuerpo."</table>";
   
    if(!
$mail->Send())
    {
       echo 
"El correo no se ha podido enviar <p>";
       echo 
"Error: " $mail->ErrorInfo;
       exit;
    }
}    
?>

/**** guardar1.php ***\
<?
$servidor
="";
$basededatos="";
$usuario="";
$clave="";
$cn=mysql_connect($servidor,$usuario,$clave) or die ("Error conectando a la base de datos");
mysql_select_db($basededatos ,$cn) or die("Error durante la seleccion de base de datos del audiweb");

$cod=$_REQUEST['cod'];
$dia date('Y-m-d');
$nom=str_replace("'","",$_REQUEST['nom']);
$estado=$_REQUEST['estado'];
$reg=$_REQUEST['reg'];
$fmemo=$_REQUEST['fmemo'];
$libro=$_REQUEST['libro'];
$inicial=$_REQUEST['inicial'];
$obs=$_REQUEST['obs'];
$inicial1=$_REQUEST['inicial1'];
$inicial2=$_REQUEST['inicial2'];
$inicial3=$_REQUEST['inicial3'];

$xlibro=$_REQUEST['xlibro'];
$xcod=$_REQUEST['xcod'];
$xbv=$_REQUEST['xbv'];
$xguias=$_REQUEST['xguias'];
$xrh=$_REQUEST['xrh'];
$xotros=$_REQUEST['xotros'];
//echo  $xlibro;

if($xlibro=='true'){
$arraylibros=split(",",$libro);
$buscar[]=21;
$inter array_intersect($arraylibros$buscar);

if(
count($inter)){
$insert="insert into libro_detalle(detalle,detall)values('$obs','$obs')";

mysql_query($insert);
$idlibro=mysql_insert_id();
$libro=str_replace("21",$idlibro,$libro);
}
}

$insertar="insert into  tbl_datos1(cod,nom,tipperdia,reg,fecha,fech)values('$cod','$nom','$estado','$reg','$fmemo','$dia')";
mysql_query($insertar);
$id=mysql_insert_id();



if(
$xlibro=='true'){
$insertar1="insert into perdida(idperdida,idlibro)values('$id','$libro')";
mysql_query($insertar1);
}
if(
$xfactura=='true'){
$insertar1="insert into perdida_cod(id_perdida,del)values('$id','$inicial')";
mysql_query($insertar1);
}
if(
$xbv=='true'){
$insertar1="insert into perdida_bv(id_perdida,del)values('$id','$inicial1')";
//echo $insertar1;
mysql_query($insertar1);
}
if(
$xguias=='true'){
$insertar1="insert into perdida_guias(id_perdida,del)values('$id','$inicial2')";
mysql_query($insertar1);
}
if(
$xrh=='true'){
$insertar1="insert into perdida_rh(id_perdida,del)values('$id','$inicial3')";

mysql_query($insertar1);
}
if(
$xotros=='true'){
$insertar1="insert into audicontrol.perdida_otros(id_perdida)values('$id')";
mysql_query($insertar1);
}

$consultar="select * ,date_format(fecha,'%d/%m/%Y') as fechas, pl.idlibro as libros,det as xlibro,pf.deta as xcod, pb.deta as xcods, pg.deta as xguias , pr.deta as xrh , po.deta as xotros,pf.del as dcod
,pb.del as dcods
,pg.del as dguias,pr.del as dxrh
from perdida p left join perdida_libro pl on p.id=pl.idperdida left join perdida_feh pf on p.id=pf.id_perdida left join  perdida_bv pb on p.id=pb.id_perdida left join  perdida_guias pg on p.id=pg.id_perdida left join  perdida_rh pr on p.id=pr.id_perdida left join  perdida_otros po on p.id=po.id_perdida  where p.id='$id'"
;
$res=mysql_query($consultar);
$row=mysql_fetch_array($res);

?>
<center><label font-size:12px"><b>Detalle del Registro</b></label></center>
<table>
<?php header("Content-Type: text/html; charset=utf-8");?> 
<tr><th><div align="center">COD</div></th><th><div align="center">Nombre</div></th><th><div align="center">tipo</div></th><th><div align="center">Reg</div></th><th><div align="center">Fecha</div></th><th><div align="center">Libro</div></th><th><div align="center">FRECS</div></th><th><div align="center">B/V</div></th><th><div align="center">Guias</div></th><th><div align="center">RxH</div></th><th><div align="center">Otros</div></th></tr>
<tr>
<td><div align="center"><? echo $row['cod'];?></div></td>
<td><div align="center"><? echo $row['nom'];?></div></td>
<td><div align="center"><? echo $row['tipperdia'];?></div></td>
<td><div align="center"><? echo $row['reg'];?></div></td>
<td><div align="center"><? echo $row['fecha'];?></div></td>
<td title="<? echo $row['detalle'];?>"><div align="left"><? if($row['xlibro']){

$selec="select * from compulsa_libro_detalle where idlibro in (".$row['libros'].")  ";
$res1=mysql_query($selec);

while(
$row1=mysql_fetch_array($res1)){
echo 
$row1['detalle']."<br>";
}

//echo $row['xlibro'];

}else{echo "-";}?></div></td>
<td ><div align="center"><? if($row['dfra']){echo $row['dfra']."<br>(".$row['dfra'].")";}else{echo "-";}?></div></td>
<td><div align="center"><? if($row['dbta']){echo $row['dbta']."<br>(".$row['dbta'].")";}else{echo "-";}?></div></td>
<td><div align="center"><? if($row['xguias']){echo $row['xguias']."<br>(".$row['dguias'].")";}else{echo "-";}?></div></td>
<td><div align="center"><? if($row['xrh']){echo $row['xrh']."<br>(".$row['dxrh'].")";}else{echo "-";}?></div></td>
<td><div align="center"><? if($row['xotros']){echo $row['xotros'];}else{echo "-";}?></div></td>

</tr>
</table>
<script type='text/javascript' src='../../includes/js/jquery.js'></script>
<script type="text/javascript" src="../../includes/js/jquery.min.js"></script>

<script>
 $(document).ready(function(){

setTimeout(function(){$("#formulario1").load("usuarios/blanc.php"),$("#cod").val(''),$("#nom").val(''),$("#reg").val(''),$("#fmemo").val(''),resetear()}, 6000);  
//setTimeout(function(){$("#formulario1").load("default.php?op=1034"),$("#cod").val(''),$("#nom").val(''),$("#reg").val(''),$("#fmemo").val(''),resetear()}, 6000);  

});

function resetear(){

$("#libr").hide();
$("#fa").hide();
$("#bta").hide();
$("#gr").hide();
$("#rh").hide();
$("#comp1").hide();
$("#comp2").hide();
$("#inicial").val('');
$("#inicial1").val('');
$("#inicial2").val('');
$("#inicial3").val('');
$("#obs").val('');
$("#a1").hide();

$(".julio").attr('checked',false);

$("#xlibro").attr('checked',false);
$("#xfactura").attr('checked',false);
$("#xbv").attr('checked',false);
$("#xguias").attr('checked',false);
$("#xrh").attr('checked',false);
$("#xotros").attr('checked',false);
$("#Comprobantes").attr('checked',false);
}
</script>
  #2 (permalink)  
Antiguo 20/04/2016, 09:13
Avatar de pateketrueke
Modernizr
 
Fecha de Ingreso: abril-2008
Ubicación: Mexihco-Tenochtitlan
Mensajes: 26.399
Antigüedad: 16 años
Puntos: 2534
Respuesta: Enviar Funciones en php

Pues eso es muy fácil, yo diría, básico:
Código PHP:
Ver original
  1. include 'script_con_funciones.php';
  2.  
  3. la_funcion_a_ejecutar();
__________________
Y U NO RTFM? щ(ºдºщ)

No atiendo por MP nada que no sea personal.
  #3 (permalink)  
Antiguo 20/04/2016, 11:06
 
Fecha de Ingreso: noviembre-2015
Mensajes: 21
Antigüedad: 8 años, 5 meses
Puntos: 0
Respuesta: Enviar Funciones en php

Disculpa pero en que parte del codigo iria
  #4 (permalink)  
Antiguo 20/04/2016, 11:53
Avatar de pateketrueke
Modernizr
 
Fecha de Ingreso: abril-2008
Ubicación: Mexihco-Tenochtitlan
Mensajes: 26.399
Antigüedad: 16 años
Puntos: 2534
Respuesta: Enviar Funciones en php

Cita:
Iniciado por tvreal28 Ver Mensaje
Disculpa pero en que parte del codigo iria
¿Pues en la parte que necesites usar dicha función?

Creo que deberías leer un manual básico al respecto, te hace falta.
__________________
Y U NO RTFM? щ(ºдºщ)

No atiendo por MP nada que no sea personal.

Etiquetas: fecha, formulario, funciones, html, mysql, registro, select, sql
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 23:41.