I have the following code
require('db.php');
if($_POST['id']);
{
for($i=0; $i<count($_POST['id']); $i++)
{
$msjn=$_POST['mensaje'];
$idfoto=$_POST['id'];
$nomb=$_POST['nombre'];
$r1=$_POST['responsable1'];
$r2=$_POST['responsable2'];
$esms=$_POST['estado_sms'];
$conc=$_POST['concepto'];
$fc=$_POST['fecha'];
$d=$_POST['dia'];
$m=$_POST['mes'];
$an=$_POST['ano'];
$cm=$_POST['cm'];
$nmob=$_POST['mobile'];
$query="INSERT INTO sms (id, nombre, responsable1, responsable2, estado_sms, concepto, fecha, mobile, mensaje, dia, mes, ano) VALUES ('".$idfoto[$i]."','".$nomb[$i]."','".$r1[$i]."','".$r2[$i]."','".$esms[$i]."','".$conc."','".$fc[$i]."','".$nmob[$i]."','".$msjn."','".$d."','".$m."','".$an."')";
$r = $conexion->query($query);
//envio del sms
$umob=implode($nmob);
header("Location: https://sms.net/eapi/submission/send_sms/2/2.0?username=".$usuario."&password=".$pass."&message=".$msjn."&msisdn=".$umob."".$telf."");
//Aqui debe redireccionarme a la pagina principal
$alerta="Mensaje enviado Exitosamente!";
header("Location: ../pagina_principal.php?msj=".$alerta." ");
}
}
The problem I have is that if I comment on the second header ("Location: ..") which redirects me to the main page, it redirects me perfectly and sends me the sms, it also inserts the data.
When I use the two header ("Location: ..") I insert the data correctly and redirect me with the message to the main page but do not send me the sms, as I can send these two header correctly.