By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,876 Members | 1,239 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,876 IT Pros & Developers. It's quick & easy.

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

P: n/a
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!

Mar 20 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Duderino82 wrote:
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!

How are you setting the value of $delete?
Something like $delete = isset($_GET['del']);

-david-

Mar 20 '06 #2

P: n/a
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".

Mar 21 '06 #3

P: n/a
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_processori($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($str, $db) or die("Query non valida: " .
mysql_error());
header ("Location: $redirect");
}
}
mysql_close($db);

}

Mar 21 '06 #4

P: n/a
> if ($delete)
{ 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.


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.

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

ECRIA
http://www.ecria.com
Mar 21 '06 #5

P: n/a
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
remains!

Mar 21 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.