haroon Posted June 2, 2007 Share Posted June 2, 2007 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"); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/53962-problem-with-code/ Share on other sites More sharing options...
DeathStar Posted June 2, 2007 Share Posted June 2, 2007 Meta tags? Quote Link to comment https://forums.phpfreaks.com/topic/53962-problem-with-code/#findComment-266769 Share on other sites More sharing options...
wildteen88 Posted June 2, 2007 Share Posted June 2, 2007 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? Quote Link to comment https://forums.phpfreaks.com/topic/53962-problem-with-code/#findComment-266808 Share on other sites More sharing options...
taith Posted June 2, 2007 Share Posted June 2, 2007 also... you need your exit; command after the header... Quote Link to comment https://forums.phpfreaks.com/topic/53962-problem-with-code/#findComment-266811 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.