maliary Posted April 27, 2007 Share Posted April 27, 2007 I am using the following insert script in a form with executes on the same page using action="<?php echo $_SERVER['PHP_SELF'] ?>" . however the redirect does not work.Instead it refreshes itself... How would i go about this?? $lok = 1; $pn=$_POST['encounter_nr'] ; $SQL ="INSERT INTO $dbtable (`date`,`hospital`,`doctor`,`exam_type`,`diagnosis`,`doc_comm`,`encounter_nr`,`pid`,`modify_id`,`create_id`,`history`) VALUES ('$_POST[date]','$_POST[hospital]','$_POST[doctor]','$_POST[exam_type]','$_POST[diagnosis]','$_POST[doc_comm]','$_POST[encounter_nr]','$_POST[pid]','$_POST[modify_id]','$_POST[create_id]','$_POST[history]')"; $result = mysql_db_query($db,"$SQL",$cid) or die(mysql_error()); if ($result) { header("Location:../labs/labs_discharge.php?pn=".$pn."&user=".$lok); /* Redirect browser */ } Link to comment https://forums.phpfreaks.com/topic/48953-redirect/ Share on other sites More sharing options...
ballhogjoni Posted April 27, 2007 Share Posted April 27, 2007 Try something like this <?php function redirect($filename="http://www.xxxxxx.php", $delay="0", $die="0"){ if((!headers_sent())&&($delay=="0")) { header("Location:$filename"); } elseif($delay=="0"){ echo '<script type="text/javascript">'; echo 'window.location.href="'.$filename.'";'; echo '</script>'; echo '<noscript>'; echo '<meta http-equiv="refresh" content="0;url='.$filename.'" />'; echo '<noscript>'; } else { echo '<meta http-equiv="refresh" content="'.$delay.';url='.$filename.'" />'; } }?> Link to comment https://forums.phpfreaks.com/topic/48953-redirect/#findComment-239835 Share on other sites More sharing options...
maliary Posted April 27, 2007 Author Share Posted April 27, 2007 Thanks, How do i actually use the script on what I have above? Maliary Link to comment https://forums.phpfreaks.com/topic/48953-redirect/#findComment-239852 Share on other sites More sharing options...
ballhogjoni Posted April 28, 2007 Share Posted April 28, 2007 <?php function redirect($filename="http://www.xxxxxx.php", $delay="0", $die="0"){ if((!headers_sent())&&($delay=="0")) { header("Location:$filename"); } elseif($delay=="0"){ echo '<script type="text/javascript">'; echo 'window.location.href="'.$filename.'";'; echo '</script>'; echo '<noscript>'; echo '<meta http-equiv="refresh" content="0;url='.$filename.'" />'; echo '<noscript>'; } else { echo '<meta http-equiv="refresh" content="'.$delay.';url='.$filename.'" />'; } } if ($result) { redirect($filename); // don't use the header() its too problematic } Link to comment https://forums.phpfreaks.com/topic/48953-redirect/#findComment-240280 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.