执行mysql查询时URL不正确(不遵循php的标题位置说明)

Importante note: I have set Location to 'Location:google.com'; and it neither works. This should make it easyer to detect problem, de you know why could it not redirect to google?? The entire code has been added at the end of the post.


I've been stuck here for time, and got no idea of what's happening.

On a form, when I click on submit button, my browser redirects me to a inexisting directory (localhost/Gestion/school_main.php), forgetting about instructions given by header(location:...)

FORM mysql query:

    if (mysql_num_rows($consultaCampos)==0) {
    $nuevoRegistro = mysql_query("INSERT INTO school_main(sc_id,sc_name,sc_cif,sc_web,sc_headmstr,sc_studDirector,sc_dir1,sc_dir2,sc_dir3,sc_dir4,sc_postcode,sc_pobl,sc_city,sc_country,sc_tel1sec,sc_tel1,sc_tel2sec,sc_tel2,sc_fax,sc_mail1sec,sc_mail1,sc_mail2sec,sc_mail2,sc_mail3sec,sc_mail3,sc_img) VALUE ('','$nombre','$cif','$web','$director','$jefeEstudios','$direccion1','$direccion2','$direccion3','$direccion4','$codigopostal','$poblacion','$ciudad','$pais','$seccionTelefono1','$telefonol','$seccionTelefono2','$telefono2','$fax','$seccionEmail1','$email1','$seccionEmail2','$email2','$seccionEmail3','$email3','$rutaFinal')") or die("No se pudo introducir contenido en la base de datos");

    header('location:/Gestion/panel.php?directory=forms/school_main/school_main');
}

else{
    $idCentro=$registroBbdd['sc_id'];
    $actualizaRegistro = mysql_query("UPDATE school_main SET sc_name='$nombre',sc_cif='$cif',sc_web='$web',sc_headmstr='$director',sc_studDirector='$jefeEstudios',sc_dir1='$direccion1',sc_dir2='$direccion2',sc_dir3='$direccion3',sc_dir4='$direccion4',sc_postcode='$codigopostal',sc_pobl='$poblacion',sc_city='$ciudad',sc_country='$pais',sc_tel1sec='$seccionTelefono1',sc_tel1='$telefonol',sc_tel2sec='$seccionTelefono2',sc_tel2='$telefono2',sc_fax='$fax',sc_mail1sec='$seccionEmail1',sc_mail1='$email1',sc_mail2sec='$seccionEmail2',sc_mail2='$email2',sc_mail3sec='$seccionEmail3',sc_mail3='$email3',sc_img='$rutaFinal' WHERE sc_id='$idCentro'") or die("No se pudo actualizar el contenido de la base de datos");

    header('location:/Gestion/panel.php?directory=shortcuts');

}

And the piece of panel.php involved on this process:

    if(!$_GET)
{
        include('config/shortcuts.php');
}
else
{   
    $directorio = $_GET['directory'];


            include('config/'.$directorio.'.php');

}

As you see on the FORM, under any circunstance it must take me to localhost/Gestion/school_main.php, but even if there are rows on $consultaCampos as if not, it always takes me there, where no document exists under that name... it should take me to school_main.php or to shortcuts.php

what am I missing? Thank you for your patience and attention. Any aditional info/code just tell me.

I hope this helps, I have written a webpage that uses the header location. Maybe you can see if you did something incorrectly:

    <html>
<head>
<link rel="stylesheet" type="text/css" href="./static/css/mobile-login.css">
<!-- <link rel="stylesheet" type="text/css" href="./static/css/mobile.css"> -->

<script>
function goBack()
{
window.history.back()
}
</script>

<title>Register | Mobile</title>
</head>
<body background="../images/mobile/login-bkg.jpg">
<center>
<a href="http://localhost/m/">
<img src="../static/images/logo.png">
</a>
</center>
<div id="login-panel" class="panel">
<div class="panel-container">

<?php
// Create connection
$con=mysqli_connect("localhost","root","","twitter");

// Check connection
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }

        $email      = isset($_POST['email'])?( strtolower(trim($_POST['email'])) ):'';
    $fullname   = isset($_POST['name'])?(trim($_POST['name'])):'';
    $username   = isset($_POST['username'])?(trim($_POST['username'])):'';
    $password2  = isset($_POST['password2'])?(trim($_POST['password2'])):'';
    $password   = isset($_POST['password'])?(trim($_POST['password'])):'';
        $accept_terms   = isset($_POST['accept_terms'])&&$_POST['accept_terms']==1;

    // Check for duplicate entries
    $result = mysqli_query($con, "SELECT  * FROM users WHERE email='$email'");
    if($result) {
        echo 'That email was already used';
        echo '<strong> <button onclick="goBack()">Go back</button></strong><br>';
    }

    // handle the error of the passwords not matching
    if ($password != $password2){
    echo 'Passwords did not match. Go back and try again, <a href="http://localhost/mobile_register.php">return</a>';
}else{
$sql="INSERT INTO users (fullname, username, email, password)
VALUES
('".$fullname."','".$username."','".$email."',MD5('".$password."'))";

if (!mysqli_query($con,$sql))
  {
  die('Error: ' . mysqli_error($con));
  }
echo "You are now registered<br>";
echo "<a href='http://localhost/m/'>Login</a>";
}
mysqli_close($con);
header("Location:http://localhost/m/");
?>
</div>
</div>
<div class="clear"></div>
</body>
</html>