Deseo enviar un correo en el mismo momento que se ejecuta una accion de guardar datos en una BD, esta parte ya esta funcionando y la web para que envie el correo tambien esta funcionando pero me gustaria que cuando se llame la accion de actualizar se ejecute tambien enviar.php
en el index.php
Código PHP:
<?php
session_start();
if(!isset($_SESSION["user_id"]) || $_SESSION["user_id"]==null){
print "<script>alert(\"Acceso invalido!\");window.location='../../login.php';</script>";
}
require_once 'usuario.entidad.php';
require_once 'usuario.model.php';
// Logica
$alm = new Usuario();
$model = new UsuarioModel();
if(isset($_REQUEST['action']))
{
switch($_REQUEST['action'])
{
case 'actualizar':
$alm->__SET('id', $_REQUEST['id']);
$alm->__SET('Rif', $_REQUEST['Rif']);
$alm->__SET('Nombre', $_REQUEST['Nombre']);
$alm->__SET('Producto', $_REQUEST['Producto']);
$alm->__SET('sistema_enc', $_REQUEST['sistema_enc']);
$alm->__SET('nro_cupon', $_REQUEST['nro_cupon']);
$alm->__SET('fecha_envio', $_REQUEST['fecha_envio']);
$alm->__SET('nota', $_REQUEST['nota']);
$model->Actualizar($alm);
header('Location: index.php');
break;
case 'registrar':
$alm->__SET('Rif', $_REQUEST['Rif']);
$alm->__SET('Nombre', $_REQUEST['Nombre']);
$alm->__SET('Producto', $_REQUEST['Producto']);
$alm->__SET('sistema_enc', $_REQUEST['sistema_enc']);
$alm->__SET('nro_cupon', $_REQUEST['nro_cupon']);
$alm->__SET('fecha_envio', $_REQUEST['fecha_envio']);
$alm->__SET('nota', $_REQUEST['nota']);
$model->Registrar($alm);
header('Location: index.php');
break;
case 'enviar':
$alm->__SET('Rif', $_REQUEST['Rif']);
$alm->__SET('Nombre', $_REQUEST['Nombre']);
$alm->__SET('Producto', $_REQUEST['Producto']);
$alm->__SET('sistema_enc', $_REQUEST['sistema_enc']);
$alm->__SET('nro_cupon', $_REQUEST['nro_cupon']);
$alm->__SET('fecha_envio', $_REQUEST['fecha_envio']);
$alm->__SET('nota', $_REQUEST['nota']);
$model->enviar($alm);
header('Location: ../mail/envio.php');
break;
case 'eliminar':
$model->Eliminar($_REQUEST['id']);
header('Location: index.php');
break;
case 'editar':
$alm = $model->Obtener($_REQUEST['id']);
break;
}
}
?>
<!DOCTYPE html>
<html lang="es">
<head>
<title>SIGENVIOS</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" >
<link rel="stylesheet" type="text/css" href="../../../admin/config/css/estilo2.css">
</head>
<body style="padding:15px;">
<div class="pure-g">
<div class="pure-u-1-12">
<form action="?action=<?php echo $alm->id > 0 ? 'actualizar' : 'registrar'; ?>" method="post" class="pure-form "style="margin-bottom:30px;">
<input type="hidden" name="id" value="<?php echo $alm->__GET('id'); ?>" />
<table style="width:500px;">
<tr>
<th style="text-align:left;">Rif</th>
<td><input type="text" name="Rif" value="<?php echo $alm->__GET('Rif'); ?>" style="width:100%;" /></td>
</tr>
<tr>
<th style="text-align:left;">Nombre</th>
<td><input type="text" name="Nombre" value="<?php echo $alm->__GET('Nombre'); ?>" style="width:100%;" /></td>
</tr>
<tr>
<th style="text-align:left;">Producto</th>
<td><input type="text" name="Producto" value="<?php echo $alm->__GET('Producto'); ?>" style="width:100%;" /></td>
</tr>
<tr>
<th style="text-align:left;">Encomienda</th>
<td><input type="text" name="sistema_enc" value="<?php echo $alm->__GET('sistema_enc'); ?>" style="width:100%;" /></td>
</tr>
<tr>
<tr>
<th style="text-align:left;">Numero Cupon</th>
<td><input type="text" name="nro_cupon" value="<?php echo $alm->__GET('nro_cupon'); ?>" style="width:100%;" /></td>
</tr>
<tr>
<th style="text-align:left;">Fecha de Envio</th>
<td><input type="text" name="fecha_envio" value="<?php echo $alm->__GET('fecha_envio'); ?>" style="width:100%;" /></td>
</tr>
<tr>
<th style="text-align:left;">Nota</th>
<td><input type="text" name="nota" value="<?php echo $alm->__GET('nota'); ?>" style="width:100%;" /></td>
</tr>
<tr>
<td colspan="2">
<button type="submit" class="pure-button pure-button-primary">Guardar</button>
</td>
</tr>
</table>
</form>
<table class="pure-table pure-table-horizontal">
<thead>
<tr>
<th style="text-align:left;">Rif</th>
<th style="text-align:left;">Nombre</th>
<th style="text-align:left;">Producto</th>
<th style="text-align:left;">Encomienda</th>
<th style="text-align:left;">Nro Cupon</th>
<th style="text-align:left;">Fecha Envio</th>
<th style="text-align:left;">Nota</th>
<th></th>
<th></th>
</tr>
</thead>
<?php foreach($model->Listar() as $r): ?>
<tr>
<td><?php echo $r->__GET('Rif'); ?></td>
<td><?php echo $r->__GET('Nombre'); ?></td>
<td><?php echo $r->__GET('Producto'); ?></td>
<td><?php echo $r->__GET('sistema_enc'); ?></td>
<td><?php echo $r->__GET('nro_cupon'); ?></td>
<td><?php echo $r->__GET('fecha_envio'); ?></td>
<td><?php echo $r->__GET('nota'); ?></td>
<td>
<a href="?action=editar&id=<?php echo $r->id; ?>">Editar</a>
</td>
<td>
<!-- esta linea activa la opcion de borrar row de mysql-->
<a href="?action=eliminar&id=<?php echo $r->id; ?>">Eliminar</a>
</td>
</tr>
<?php endforeach; ?>
</table>
</div>
</div>
</body>
</html>
Código PHP:
<?php
$rif= $_REQUEST['Rif'];
$nombre= $_REQUEST['Nombre'];
$producto= $_REQUEST['Producto'];
$sistema_enc= $_REQUEST['sistema_enc'];
$nro_cupon= $_REQUEST['nro_cupon'];
$fecha_envio= $_REQUEST['fecha_envio'];
$nota= $_REQUEST['nota'];
$from="JESYMCA SISTEMA INTERNO";
$to="[email protected]";
$asunto="Test desde Archivo Mail PHP";
$msg='<html>
<head>
<title>Actualizacion en Status de Despacho</title>
</head>
<body>
<table>
<tr><td>
<img src="http://www.jesuministrosymas.com.ve/LOGO.png" width="400" height="74" alt="J.E SUMINISTROS Y MAS, C.A." longdesc="LOGO J.E SUMINISTROS Y MAS, C.A." id="logo" align="left">
</tr></td>
<tr>
<td>Saludos Cordiales Estimado/a '. $nombre.'</td>
</tr>
<tr>
<td>Sally</td>
</tr>
</table>
</body>
</html>';
$cabeceras = 'MIME-Version: 1.0' . "\r\n";
$cabeceras .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$cabeceras .= "To: $to" . "\r\n";
$cabeceras .= "From: $from" . "\r\n";
// mail($to,$subj,$msg,"From: $from");
$res = mail ( $to, $asunto, $msg,$cabeceras);
var_export( $res );
?>