Jump to content


Photo

*SOLVED* Header Redirection


  • Please log in to reply
2 replies to this topic

#1 avo

avo
  • Members
  • PipPipPip
  • Advanced Member
  • 148 posts
  • Locationstaffordshire uk

Posted 28 May 2006 - 07:00 PM

HI All

Can anyone shed some light on this for me please as you can see from my code bellow there are three header redirect each doing redirection IF but i can not get the second redirection to work any ideas please it simply will not redirect .

<?     
include ('includes/dbconfig.php');

if ($_POST['del_no']){
header ('location: retrive_admin_message.php');
}


if($_GET["del_msg"] && $_GET["msgnumber"]==""){?>
<form id="form2" name="form2" method="Get" action="retrieve_admin_message.php">
  <input type="hidden" name="msg_no" />
</form><?
header ('location: retrive_admin_message.php');
exit ();
} else {

if ($_POST['del_yes']){
//connect to db
mysql_connect ($dbhost, $dbuser, $dbpass);
mysql_select_db ($dbname) or die ( mysql_error ());
$sql = "DELETE FROM user_messages WHERE id='".$_GET["msgnumber"]."'";
mysql_query($sql) or die (mysql_error ());
$deleted = '<span class="style9 style23">Message Deleted!</span>';
header ('location: retrive_admin_message.php');
}}

Im loving it ........

#2 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 28 May 2006 - 07:48 PM

Header() will not work if you have sent any output to the browser. You are sending form data before that second header.

Try

if($_GET["del_msg"] && $_GET["msgnumber"]==""){?>
    $msg = $_GET["msgnumber"];
    header ("location: retrive_admin_message.php?name=$msg");
    exit ();
} else {

If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#3 avo

avo
  • Members
  • PipPipPip
  • Advanced Member
  • 148 posts
  • Locationstaffordshire uk

Posted 28 May 2006 - 07:56 PM

[!--quoteo(post=377907:date=May 28 2006, 08:48 PM:name=Barand)--][div class=\'quotetop\']QUOTE(Barand @ May 28 2006, 08:48 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Header() will not work if you have sent any output to the browser. You are sending form data before that second header.

Try

if($_GET["del_msg"] && $_GET["msgnumber"]==""){?>
    $msg = $_GET["msgnumber"];
    header ("location: retrive_admin_message.php?name=$msg");
    exit ();
} else {
[/quote]

Thank you

I understand i can now work with that

cheers.
Im loving it ........




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users