www.webdeveloper.com
Results 1 to 5 of 5

Thread: Help with header()

  1. #1
    Join Date
    Mar 2012
    Posts
    7

    Help with header()

    I'm not able to get with this:
    My page doesn't go to another page, after a table update. Can someone help me with it? Whtat's wrong with my header() (last lines of the code).
    With the following code, the page stays in the same (but it gets a white page, completely empty)
    My code:

    PHP Code:
    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
        
    $name $_FILES['anexo']['name'];
        
    $tmp_name $_FILES['anexo']['tmp_name'];
        
    $location "clientes/anexos_consultas/".$name;
        if (
    $name) {
            
    move_uploaded_file($tmp_name,$location);
            }
            else {
                
    $location "";
            }
      
    $insertSQL sprintf("INSERT INTO clientes_consultas (id_consulta, id_cliente, id_contacto, datarecepcao, meiocomunicacao, caminhoresposta, referenciaconsulta, anexo, validadeconsulta, criadopor_loop, datacriacao, tituloconsulta, referencia_loop, estado) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                           
    GetSQLValueString($_POST['id_consulta'], "int"),
                           
    GetSQLValueString($id_cliente"int"),
                           
    GetSQLValueString($_POST['id_contacto'], "int"),
                           
    GetSQLValueString($_POST['datarecepcao'], "text"),
                           
    GetSQLValueString($_POST['meiocomunicacao'], "int"),
                           
    GetSQLValueString($_POST['caminhoresposta'], "int"),
                           
    GetSQLValueString($_POST['referenciaconsulta'], "text"),
                              
    GetSQLValueString($name"text"),
                           
    GetSQLValueString($_POST['validadeconsulta'], "text"),
                           
    GetSQLValueString($_SESSION['MM_Userid'], "int"),
                           
    GetSQLValueString(date("Y-m-d"), "date"),
                           
    GetSQLValueString($_POST['tituloconsulta'], "text"),
                           
    GetSQLValueString($_POST['referencia_loop'], "text"),
                           
    GetSQLValueString('11'"int"));

      
    mysql_select_db($database_connLOOPGEST$connLOOPGEST);
      
    $Result1 mysql_query($insertSQL$connLOOPGEST) or die(mysql_error());
      
    $UltimoID mysql_insert_id();

      
    $insertGoTo "c_editaconsulta.php";
      if (isset(
    $_SERVER['QUERY_STRING'])) {
        
    $insertGoTo .= (strpos($insertGoTo'?')) ? "&" "?";
        
    $insertGoTo .= $_SERVER['QUERY_STRING'];
      }
      
    header(sprintf("Location: %s"$insertGoTo));
      exit;

    Tanks in advance,
    Mário
    Last edited by mjcordeiro; 03-27-2012 at 12:17 PM.

  2. #2
    Join Date
    Dec 2005
    Posts
    2,984
    HTTP/1.1 requires an absolute URI as argument to » Location: including the scheme, hostname and absolute path, but some clients accept relative URIs. You can usually use $_SERVER['HTTP_HOST'], $_SERVER['PHP_SELF'] and dirname() to make an absolute URI from a relative one yourself
    http://php.net/manual/en/function.header.php
    I've switched careers...
    I'm NO LONGER a scientist,
    but now a web developer...
    awesome.

  3. #3
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,245
    Also make sure nothing has already been output to the browser, since headers cannot then be sent. If you need to test for that within the code, use the headers_sent() function.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  4. #4
    Join Date
    Dec 2002
    Location
    St. Louis, MO, USA
    Posts
    1,582
    I use output buffering if I'm going to be using header() for redirects. That way, nothing gets sent until all processing is completed, so header() will be used before anything else is sent.
    |||||
    o . Q
    ___ "You live and you learn; or you don't live long." - Lazarus Long

    ^_^

  5. #5
    Join Date
    Mar 2012
    Posts
    7
    Thank you all for your help,
    At the moment I'm on vacations. I will try that when I went home, after eastern.
    Thank you once more.
    Best regards,
    Mário

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles