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

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
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");

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!

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

Duderino82 wrote:
Quoted text here. Click to load it
How are you setting the value of $delete?
Something like $delete = isset($_GET['del']);


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

I always have the following in my coding section:

if (isset($_POST['delete'])) {

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".

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

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


Re: header("Location: ..."); 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...mistery

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

Quoted text here. Click to load it

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."&table=".$tab to verify that they are  
correct and your script is entering the delete condition.

// ... your code here


Site Timeline