jesushax Posted August 22, 2008 Share Posted August 22, 2008 hi below is my code for adding records to an archive so the user clicks the recorsd to archive, they get archived but they dont get redirected, it just stays on the current page?action=archive the same with delete too, anyone know why? Thanks <?php switch(@$_GET["action"]) { Case "delete": include($_SERVER['DOCUMENT_ROOT'] . '/includes/connection.php'); session_start(); include($_SERVER['DOCUMENT_ROOT'] . '/includes/access.inc'); $VacID = $_GET["ID"]; mysql_query("DELETE FROM tblVac WHERE VacID='$VacID'") or die(mysql_error()); header("/admin/vacancies/edit_vac_list.asp?CAT=$CAT"); break; Case "archive"; include($_SERVER['DOCUMENT_ROOT'] . '/includes/connection.php'); session_start(); include($_SERVER['DOCUMENT_ROOT'] . '/includes/access.inc'); if(is_array($_POST['checkbox'])){ foreach($_POST['checkbox'] as $VacID){ mysql_query("UPDATE tblVac SET VacArchive='1' WHERE VacID='$VacID'") or die(mysql_error()); } } header("/admin/vacancies/edit_vac_list.asp?CAT=".$_SESSION["CAT"].""); break; default: session_start(); include($_SERVER['DOCUMENT_ROOT'] . '/includes/header.php'); include($_SERVER['DOCUMENT_ROOT'] . '/includes/access.inc'); $_SESSION["CAT"] = $_GET["CAT"]; $CAT = $_SESSION["CAT"]; echo '<div id="subheader"> <div class="padding"> <table width="100%" border="0"> <tr> <td><h2 class="titles">Vacancies</h2> Please feel free to browse and if you have any questions please use our contact form.</td> <td style="text-align:right;"><img src="/images/layout/puddle.png" alt="logo splash" /></td> </tr> </table> </div> </div> <div id="main"> <div class="right_side">'."\n"; echo '<p>Currently viewing '.$CAT.' Vacancies</p>'."\n"; echo '<form>'."\n"; echo '<select name="url">'."\n"; $SEL = mysql_query("SELECT VacCat FROM tblVac GROUP BY VacCat") or die(mysql_error()); echo'<option value="None">Change category here ---></option>'."\n"; while ($opt = mysql_fetch_array($SEL)) { echo '<option value="'.$_SERVER['PHP_SELF'].'?CAT='.$opt['VacCat'].'">'.$opt['VacCat'].'</option>'."\n"; } echo '</select>'."\n"; echo '<input type="button" value="Go" onClick="JumpToIt(this.form)" />'."\n"; echo '</form>'."\n"; $VACSQL = mysql_query("SELECT * FROM tblVac WHERE VacCat='$CAT' AND VacArchive='0' ORDER BY VacDateAdded DESC") or die(mysql_error()); if (mysql_num_rows($VACSQL) <1) { echo '<p>There currently no vacancies for this category</p>'."\n"; echo '<p><a href="/admin/vacancies/default.php">Back to category select</a></p>'."\n"; } else { echo '<form id="archive" method="post" action="'.$_SERVER['PHP_SELF'].'?action=archive">'."\n"; echo '<table width="100%"><tr style="font-weight:bold;"><td>Vac Title</td><td class="center">Date Added</td><td class="center">Date Modified</td><td class="center">Edit</td><td class="center">Archive</td><td class="center">Delete</td></tr>'."\n"; while ($row = mysql_fetch_array($VACSQL)) { echo "<tr><td>"; echo $row["VacTitle"]."</td><td style=\"text-align:center;\">"."\n"; mydate($row["VacDateAdded"]); echo '</td><td style="text-align:center;">'."\n"; if (empty($row["VacDateModified"])) { echo " "; } else { if ($row["VacDateModified"] != "0000-00-00") { mydate($row["VacDateModified"]); } } echo '</td><td class="center"><a href="/admin/vacancies/edit_vacancy.php?ID='.$row["VacID"].' ">Edit</a></td>'."\n"; echo '<td class="center"><input class="noborder" name="checkbox[]" type="checkbox" value="'.$row['VacID'].'"/></td>'."\n"; echo '<td class="center"><a href="'.$_SERVER['PHP_SELF'].'?action=delete&ID='.$row["VacID"].' ">Delete</a></td>'."\n"; echo "</tr>"."\n"; } echo ' <tr style="height:50px;"><td colspan="6" class="right"><input type="submit" value="Add Records to Archive" /></td></tr> '."\n"; echo "</table></form>"."\n"; } include($_SERVER['DOCUMENT_ROOT'] . '/includes/footer.php'); break; } ?> Link to comment https://forums.phpfreaks.com/topic/120864-arching-code-does-not-redirect/ Share on other sites More sharing options...
BlueSkyIS Posted August 22, 2008 Share Posted August 22, 2008 well, first i'd indent your code so it is easier to read. then i'd put exit; after each header(). if that doesn't fix it, i'd put in debug code to see what's happening. Link to comment https://forums.phpfreaks.com/topic/120864-arching-code-does-not-redirect/#findComment-623035 Share on other sites More sharing options...
akitchin Posted August 22, 2008 Share Posted August 22, 2008 turn display_errors on; i would guess you're outputting to the browser in one of those includes, causing the header()s to fail. Link to comment https://forums.phpfreaks.com/topic/120864-arching-code-does-not-redirect/#findComment-623121 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.