Jump to content

redirect


maliary

Recommended Posts

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

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

<?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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.