DamienRoche Posted January 3, 2009 Share Posted January 3, 2009 I have no idea what's going on here. all relevant code is on the same page sow ill include it in a sec. The issue here is that I am redirecting using a header if there is missing data in the form, but then trying to display the form as it was, on submit. I am successfully registering an error message with a session and dsiplaying this but for some reason the form POST is coming through. EDIT: I am also able to submit the form data to the database when there are no headers. Any ideas... <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head><META name="robots" content="NOINDEX,NOFOLLOW" /> <link rel="stylesheet" type="text/css" href="../template/style.css" media="screen,projection,print"> <title>Category Management</title> <style> </style> </head> <?php session_start(); include($_SERVER["DOCUMENT_ROOT"].'rev/includes/config.php'); include($root.'rev/includes/funcs.php'); include($root.'rev/comvars.php'); ############## NOTE WORTHY FUNCTIONS FROM EXTERNAL FILE: funcs.php function err($num){ $_SESSION['e'] .="-$num"; } function regvar($var, $val){ $_SESSION[$var] = "$val"; } function unvar($var){ unset($_SESSION[$var]); } ################ BASIC USER INPUT MANAGEMENT $err = clean($_SESSION['e'],$no1, "Error"); if(!empty($err)){ $err = explode("-", $err); } $ntc = clean($_GET['n'],$no1, "Notice"); if(!empty($ntc)){ $ntc = explode("-", $ntc); } $act = clean($_GET['a'], $no1, "Action Command"); $maincat = clean($_POST['maincat'], $no1, "Category"); $mainkey = clean($_POST['mainkey'], $no1, "Keywords"); #################### SESSION MANAGEMENT regvar("mcat", $maincat);regvar("mkey", $mainkey);regvar("order",$order); if($act == "create"){ if(empty($maincat) || empty($mainkey)){ err(1);header('location:'.basename(__FILE__).'?a=manage');exit;} ###################### MAIN PROBLEM AREA ^^^^^ABOVE include($root.'rev/includes/condb.php'); $insert = mysql_query("INSERT INTO cats (maincat,mainkey) VALUES('$maincat','$mainkey')") or die("mysql said:".mysql_error()); header('location:'.basename(__FILE__).'?a=manage&n=1-5'); } ?> <body id="catpage"> <div id="wrapper"> <div id="newcat"> <form action="<?php echo $phpself; ?>?a=create" method="POST"> <table> <tr class="t"><td class="label">Category</td><td><input type="text" name="maincat" value="<?php echo $maincat; ?>"/></td></tr> <tr class="k"><td class="label">Keywords</td><td><input type="text" name="mainkey" value="<?php echo $mainkey; ?>"/></td></tr> <tr class="i"><td class="label">Importance</td><td> <select name="i" value="<?php echo $order; ?>"/> <?php $n=0; while($n < 101){ echo "<option> $n </option"; $n++;} ?> </select> </td></tr> </table> <div class="submit"><input type="submit"/></div> </form> <?php if(!empty($err)){foreach($err as $er){ echo ${e.$er}."<BR>";unvar('e');}} if(!empty($ntc)){foreach($ntc as $nt){ echo ${ntc.$nt}."<br>";}} ?> </div> </div></body> Appreciate any input, thanks. Link to comment https://forums.phpfreaks.com/topic/139307-solved-session-var-not-reg-from-form-with-headerlocation/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.