Very odd that Win95/98 versions of MSIE (I presume) are ignoring your Location: header when it is followed by page content, but obeying it when it isn't. Have you tried this with the latest versions of MSIE (5.5SP2 and 6.0) on Win95/98? It definitely sounds like a browser bug.
Meanwhile, your page should definitely 'exit' after the switch-case statement if for no other reason than to avoid needlessly sending the form page to the browser along with your redirect header. To do this, simply add exit after all the form processing code has completed:
PHP Code:
<?php
$system = $HTTP_SERVER_VARS["ALL_HTTP"];
if ( isset ( $submit ) )
{
//connect to the database server
$dbcnx = @mysql_connect("localhost", "sarah", "sarah");
if (!$dbcnx)
{
echo("<P>Unable to connect to the database server at this time.</P>");
exit();
}
//select the leaf database
if (! @mysql_select_db("leaf"))
{
echo("<P> Unable to locate the <B>leaf</B> database at this time.</P>");
exit();
}
//add details to the database
$sql = "INSERT INTO author ( name, usertype, system, date) values ('$name', '$usertype', '$system', CURDATE())";
if (mysql_query($sql))
{
switch ( $usertype )
{
case "type1":
$aid = mysql_insert_id();
header("Location: b.php?aid=$aid");
break;
case "type2":
$aid = mysql_insert_id();
header("Location: b2.php?aid=$aid");
break;
case "type3":
$aid = mysql_insert_id();
header("Location: b3.php?aid=$aid");
break;
default:
print "Please make sure that you have selected one of the user type options";
}
}
else {
echo("<P>Error adding your details at this time.</P>" . mysql_error());
}
exit; // END OF SCRIPT IF FORM SUBMITTED!
}
?>
<HTML>
<HEAD>
<TITLE> leaf test page A </TITLE>
<LINK REL=STYLESHEET TYPE="text/css" TITLE="LEAF stylesheet" HREF="style.css">
</HEAD>
<BODY>
<form action="<?php echo($PHP_SELF); ?>" method=post>
<TABLE border=1 cellpadding=5 cellspacing=0 bordercolor=#ffffff width=50% align=center>
<TR>
<TD colspan=2><CENTER>FORM A</CENTER></TD>
</TR>
<TR>
<TD>Name :</TD>
<TD align=right><INPUT TYPE="text" NAME="name" SIZE="30" MAXLENGTH="100"></TD>
</TR>
<TR>
<TD>Usertype :</TD>
<TD align=right><SELECT NAME="usertype" SIZE="1">
<OPTION VALUE="type1">Usertype 1
<OPTION VALUE="type2">Usertype 2
<OPTION VALUE="type3">Usertype 3</SELECT></TD>
</TR>
<TR>
<TD colspan=2><CENTER><INPUT TYPE="submit" NAME="submit" VALUE="send"></CENTER></TD>
</TR>
</TABLE>
</form>
</BODY>
</HTML>
Bookmarks