PHP header not redirecting when using forms

ezdell

New Member
I'm doing form validation using a PHP script. I initially wrote this code in 2007 but now it just stopped working, and I've been trying to figure out why.Here's the code:\[code\]<?php$error_msg = '';// Only Validate Form when it is submittedif (isset($formSubmit)) { if (!isset($_SESSION["First_Name"])) { $get_mbr_id = urlencode ($_POST["GetMbrID"]); $_SESSION["MemberID"] = $get_mbr_id; } if (!headers_sent()) { header ("Location: mywebsite.com"); exit (0); }}if (isset($formExit)) { if (!headers_sent()) { header ('Location: mywebsiteexit.com'); exit (0); }}?><html><head></head><body><form name="select_action" method="POST" action="select_action"><br><center><input type="submit" name="formSubmit" value="http://stackoverflow.com/questions/2102449/Next"><input type="reset" name="fieldReset" value="http://stackoverflow.com/questions/2102449/Reset"><input type="submit" name="formExit" value="http://stackoverflow.com/questions/2102449/Cancel"></center></form></body></html>\[/code\]If the HTML form code is present, then the header redirect doesn't work. However, if I remove the HTML form code, change the \[code\]if(isset(formSubmit))\[/code\] statement to \[code\]if(!isset(formSubmit))\[/code\], then the header redirect will work.I can't figure what is happening with the form code that causes the \[code\]header()\[/code\] redirect not to happen.Any help would be appreciated!
 
Back
Top