header("Location: ..."); NOT WORKING!?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Duderino82

    header("Location: ..."); NOT WORKING!?

    I'm working on a very simple peace of php where basically there is a
    form and 3 buttoms. One refreshed the page, one posts the form, and
    another one (since this form contains values of a record) deletes the
    record. The sintax is this one:

    if ($delete)
    { header ("Location: $redirect?del=$ code&table=$tab ");
    exit;
    }

    where $delete is the buttom, $redirect is the string containing the url
    ("http://www...."). $code and $tab are values verified and correct.

    Well the funny thing is that this line worked well since I add the
    third buttom (the delete) after I added it even the post buttom doesn't
    work anymore. Exactly the page refreshes itself wihout changing
    parameters ($redirect contains in fact the same page but with different
    parameters) and stops loading the page after this line (probabily the
    exit() kicking in). Is there another way to redirect a page other then
    header()??? It's driving me crazy...help me!

  • David Haynes

    #2
    Re: header("Lo cation: ..."); NOT WORKING!?

    Duderino82 wrote:[color=blue]
    > I'm working on a very simple peace of php where basically there is a
    > form and 3 buttoms. One refreshed the page, one posts the form, and
    > another one (since this form contains values of a record) deletes the
    > record. The sintax is this one:
    >
    > if ($delete)
    > { header ("Location: $redirect?del=$ code&table=$tab ");
    > exit;
    > }
    >
    > where $delete is the buttom, $redirect is the string containing the url
    > ("http://www...."). $code and $tab are values verified and correct.
    >
    > Well the funny thing is that this line worked well since I add the
    > third buttom (the delete) after I added it even the post buttom doesn't
    > work anymore. Exactly the page refreshes itself wihout changing
    > parameters ($redirect contains in fact the same page but with different
    > parameters) and stops loading the page after this line (probabily the
    > exit() kicking in). Is there another way to redirect a page other then
    > header()??? It's driving me crazy...help me!
    >[/color]
    How are you setting the value of $delete?
    Something like $delete = isset($_GET['del']);

    -david-

    Comment

    • sheldonlg@gmail.com

      #3
      Re: header("Lo cation: ..."); NOT WORKING!?

      I always have the following in my coding section:

      if (isset($_POST['delete'])) {
      stuff....
      }

      I do this for all buttons that require processing.

      The other thing you can do if a redirect is all you want is to use
      straight html where you enclose the specified fields (if possible on
      your page) within a separate named form whose action is your redirect
      and whose fields are named "del" and "table".

      Comment

      • Duderino82

        #4
        Re: header("Lo cation: ..."); NOT WORKING!?

        The code is like this.
        if($_GET['modifica'] && $_GET['table']){
        // do stuff
        if(mysql_select _db($db_name, $db))
        { // do a query
        switch($table){
        case 'processori': table_processor i($row,1);
        // displays the table at the end of which are the buttoms $delete
        and $submit
        // create $str with the query
        break;
        case 'schedemadri': .......break;
        default:break;
        }
        if (isset($_POST['delete']))
        { header ("Location: $redirect");
        exit;
        }
        if (isset($_POST['submit']))
        { if(mysql_select _db($db_name, $db))
        mysql_query($st r, $db) or die("Query non valida: " .
        mysql_error());
        header ("Location: $redirect");
        }
        }
        mysql_close($db );

        }

        Comment

        • ECRIA Public Mail Buffer

          #5
          Re: header("Lo cation: ..."); NOT WORKING!?

          > if ($delete)[color=blue]
          > { header ("Location: $redirect?del=$ code&table=$tab ");
          > exit;
          > ...
          > Well the funny thing is that this line worked well since I add the
          > third buttom (the delete) after I added it even the post buttom doesn't
          > work anymore.[/color]

          Add the line below to the top of your script file, it may shed some light by
          displaying a warning or notice which would not otherwise be displayed. Also,
          after adding it, try commenting out the header() and exit() functions, and
          just echo $redirect."?del =".$code."&tabl e=".$tab to verify that they are
          correct and your script is entering the delete condition.

          error_reporting (E_ALL);
          // ... your code here

          ECRIA
          Providing a surprisingly human shopping experience. Trusted and secure. Millions of domains to choose from.



          Comment

          • Duderino82

            #6
            Re: header("Lo cation: ..."); NOT WORKING!?

            Problem solve....the funny thing is I don't know how! I just moved a
            function (not used in that part of the code) in the <head>...did a few
            errors deleting some <div>...then it when all back to normal...mister y
            remains!

            Comment

            Working...