Jump to content

Recommended Posts

Hello Guys. i am new to php. header redirection are not working with my current form. please have a look @ my code and suggest me some tips thnx.

 

<?

session_start();

include_once("Database.php");

$db=new Database;

if (isset($to_del))

{

foreach ($to_del as $v)

{

//echo"$v";

$sql="delete from e_post where id='$v'";

$db->insert($sql);

  header("location: inbox.php");

}

}

else

{

  header("location: inbox.php?Err=1");

 

}

 

?>

 

Link to comment
https://forums.phpfreaks.com/topic/53962-problem-with-code/
Share on other sites

Try moving the header redirect after the for loop. If its in the for loop PHP will only run once through the loop. You will want to move the header redirect after the loop in order for the loop to run more the once. New code:

<?php

session_start();

include_once 'Database.php';

$db = new Database;

if (isset($to_del))
{
    foreach ($to_del as $v)
    {
        //echo"$v";

        $sql="DELETE FROM e_post WHERE id='$v'";
        $db->insert($sql);
    }

    header("location: inbox.php");
}
else
{
  header("location: inbox.php?Err=1");

}

?>

If it still doesn't work could you describe what sort of output you are getting? If its a blank page then add the following at the top of your script before session_start():

error_reporting(E_ALL);
ini_set('display_errors', 'On');

 

Do you get any output now? Post any output you get here.

 

 

Also could you tell me where the variable $to_del comes from too?

Link to comment
https://forums.phpfreaks.com/topic/53962-problem-with-code/#findComment-266808
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.