estoy trabajando en un registro pero al enviarlo necesito darle al usuario un pdf con su informacion de registro de el, pero al usa fpdf depues de crear el archivo y descargarlo automaticamente quisiera poder redirecionar lo al index y asi evitar que el usuario curioso evite dar enviar y enviar el formulario muchas veces
este e mi codigo
Código PHP:
<head>
<!--Sweetaler-->
<link rel="stylesheet" type="text/css" href="dist/css/sweetalert.css">
<script src="dist/js/sweetalert-dev.js"></script>
<!-- JS -->
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
</head>
<?php
include_once 'config/funciones/recaptchalib.php';
require('config/database/conexion.php');
require('config/pdf/fpdf.php');
$test = new Recaptcha ('XXXXXXXXX');
$response = $test->verifyResponse ($_SERVER['REMOTE_ADDR'], $_POST['g-recaptcha-response']);
if (!$response->success)
{
?>
<body>
<SCRIPT LANGUAGE="Javascript">
swal({
title: "Seguro Eres Humano?",
text: "Identificate marcando el Captcha pa saber si noeres un robot!",
type: "warning",
confirmButtonColor: "#DD6B55",
confirmButtonText: "Intentar de Nuevo",
closeOnConfirm: false }, function(){ window.location.href='pruevas.html'; });
</SCRIPT>
<?php
}
else
{
$nombre = $_POST['nombre'];
$a_pa = $_POST['a_pa'];
$a_ma = $_POST['a_ma'];
$sexo = $_POST['sexo'];
$email = $_POST['email'];
$acti = $_POST['acti'];
$institu = $_POST['institu'];
$meter = mysql_query('INSERT INTO participantes (nombre, a_pa, a_ma, sexo, email, actividad, institucion) values ("'.$nombre.'", "'.$a_pa.'", "'.$a_ma.'", "'.$sexo.'", "'.$email.'", "'.$acti.'", "'.$institu.'")');
$id_ant=mysql_insert_id();
foreach($_POST['checkbox'] as $id_con)
{
$sql= mysql_query('INSERT INTO confe_asist (id_pa, id_con) values ("'.$id_ant.'", "'.$id_con.'")');
}
if($meter and $sql)
{
$partici = mysql_query("SELECT * FROM participantes where id ='$id_ant'");
$pdf = new FPDF();
$pdf->AddPage();
$pdf->Image('img/encabezado.png', 5,5,200);
$pdf->SetFont('Arial','',20);
$pdf->ln(50);
$pdf->Cell(40, 8,'Participante:', 0);
while($row = mysql_fetch_array($partici)){
$nomb=utf8_decode($row['nombre']);
$apa=utf8_decode($row['a_pa']);
$ama=utf8_decode($row['a_ma']);
$pdf->Cell(50, 8,$nomb, 0);
$pdf->Cell(50, 8, $apa, 0);
$pdf->Cell(50, 8,$ama, 0);
$pdf->Ln(10);
}
$pdf->Cell(80,10,'Numero de Registro:',0);
$pdf->Cell(30,10,'JVE'.$id_ant,0);
$pdf->ln(50);
$pdf->cell(80,10,'Registrado En',0);
$pdf->ln(10);
$consulta = mysql_query("SELECT * FROM confe_asist CA, participantes P WHERE CA.id_pa = '$id_ant' AND P.id='$id_ant'");
while($row = mysql_fetch_array($consulta)){
$id_pa=$row['id'];
$nom=$row['nombre'];
$id_con2=$row['id_con'];
$pdf->Cell(25, 8,$id_con2, 0);
$pdf->ln(10);
}
$pdf->Output('MiRegistro.pdf','D');
//no redireciona al index
sleep(10);
header('Location: index.html');
}
else{?>
<SCRIPT LANGUAGE="Javascript">
alert('Error al registar el usuario, se redirigido para intentarlo de nuevo')
</SCRIPT>
<script>
window.location.href='../../index.html';
</script>
</body>
<?php
}
}
?>