I have a problem the database is not updated when I press the button, my code is this
Form
<?php
extract($_GET);
$server = "localhost";
$usuario = "root";
$contraseña = "";
$bd = "bdpagina";
$conexion = mysqli_connect($server, $usuario, $contraseña, $bd)
or die("error en la conexion");
$sql="SELECT * FROM contribuyente WHERE id=$id";
require("connect_db.php");
$ressql=mysqli_query($conexion,$sql);
while ($row=mysqli_fetch_row ($ressql)){
$id=$row[0];
$nombre=$row[1];
$rut=$row[2];
$email=$row[3];
$phone=$row[4];
$direccion=$row[5];
$poste=$row[6];
$mensaje=$row[7];
$comentario=$row[9];
$estado=$row[8];
$fecha=$row[10];
$servicio=$row[11];
$fechares=$row[12];
}
?>
<br><form action="creaPDF.php" method="post">
<div>
<label for="nombre">¿Desea enviar el reporte?</label>
</div>
<div>
<label for="nombre">Folio:</label>
<input type="text" name="id" value= "<?php echo $id ?>" readonly="readonly"></div>
<div>
<br> <label for="nombre">Correo:</label>
<input type="text" name="email" style="" value= "<?php echo $email ?>" readonly="readonly">
</div>
<br><input type="submit" name ="recibir" value="Enviar Reporte" class="btn btn-success btn-primary">
</form>
The next code what you do is create a PDF and send it automatically to the email, send it and it creates it well but also I want that when sending the pdf the record changes state with an UPDATE.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Enviar email con archivo adjunto y cambiar estado</title>
</head>
<body>
<?php
extract($_POST);
$server = "localhost";
$usuario = "root";
$contraseña = "";
$bd = "bdpagina";
$conexion = mysqli_connect($server, $usuario, $contraseña, $bd)
or die("error en la conexion");
$sentencia = "UPDATE contribuyente SET estado = 'cerrada' WHERE contribuyente. id = '$id'";
?>
<?php
include_once('PDF.php');
include_once('myDBC.php');
$mat = $_POST['id'];
$email=$_POST['email'];
$pdf = new PDF();
$pdf->AddPage('P', 'Letter');
$pdf->SetFont('Arial','B',12);
$pdf->Cell(40,7,'ESTADO SOLICITUD',0, 1 , ' L ');
$pdf->Ln();
$pdf->ImprimirTexto('textoFijo.txt');
$consultaPersona = new myDBC();
$datosPersona = $consultaPersona->seleccionar_persona($mat);
$cabecera = array("Estado","Folio","Nombre","Rut","Email", "Telefono", "solicitud", "Observacion");
$pdf->tabla($cabecera,$datosPersona);
$pdf->Output("adjunto-temp.pdf","F");
function comprobar_email($email) {
return (filter_var($email, FILTER_VALIDATE_EMAIL)) ? 1 : 0;
}
if (isset($_POST['recibir'])) {
if (comprobar_email($_POST['email'])) {
require_once("class.phpmailer.php");
$mail = new PHPMailer();
$mail->From = "[email protected]";
$mail->FromName = "Modulo alumbrado publico";
$mail->Subject = "Respuesta a solicitud";
$mail->Body = "Estimado(a) se le ah enviado la siguiente informacion de Modulo de solicitudes alumbrado publico, se adjunta documento!!!";
$mail->IsHTML(true);
$mail->AddAddress($_POST['email'], "User Name");
$archivo = 'prueba.pdf';
$mail->AddAttachment('adjunto-temp.pdf');
$mail->Send();
echo '<script>alert("REPORTE ENVIADO")</script>';
echo "<script>location.href='admin.php'</script>";
}
else {
echo '<p>El email introducido no es correcto!</p>';
}
}
?>
What I want is that when sending the mail the request changes to closed Thank you