Jump to content

[SOLVED] Javascript Nested in Php?


ballhogjoni

Recommended Posts

Is there a way to put javascipt in this block of php code to redirect to another page? Or does anyone have a better way of doing a redirect when this block of code is executed? The header() won't work since headers have been set already.

 

<?php
if (isset($money)) {
$sql = mysql_query("SELECT * FROM contactinfo LIMIT $from, $max_results");
	while($row = mysql_fetch_array($sql)){
		if (isset($row['fname'])) {
			mysql_query("INSERT INTO dispo_Money (Name, Phone, Email, Position, State, Comments) VALUES ('$row[fname] $row[lname]','$row[areacode]$row[prefix]$row[linenumber]','$row[email]','$row[position]','$row[state]','$comments')");
			// mysql_query("DELETE FROM contactinfo WHERE email='$row[email]'");
			echo "<script
		} elseif (!isset($row['fname'])) {
			echo "<p align=\"center\">Don't Forget To Disposition the Lead.</p>";
		} else { 
			echo "<p align=\"center\"><font color=\"red\"><b>What the crap, an error! Go talk to Chris</b></font></p>";
		}
	}
}
?>

Link to comment
Share on other sites

scratch header()... too problimatic... use this...

 

<?
function redirect($filename="?", $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($die=="0"){
  db_disconnect();
  exit;
}
}
?>

Link to comment
Share on other sites

Does anybody know why this code is not redirecting to the $filename variable?

 

<?php
if (isset($money)) {
$sql = mysql_query("SELECT * FROM contactinfo LIMIT $from, $max_results");
	while($row = mysql_fetch_array($sql)){
		if (isset($row['fname'])) {
			mysql_query("INSERT INTO dispo_Money (Name, Phone, Email, Position, State, Comments) VALUES ('$row[fname] $row[lname]','$row[areacode]$row[prefix]$row[linenumber]','$row[email]','$row[position]','$row[state]','$comments')");
			// mysql_query("DELETE FROM contactinfo WHERE email='$row[email]'");
			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
Share on other sites

if(isset($money)){
$sql = mysql_query("SELECT * FROM contactinfo LIMIT $from, $max_results");
while($row = mysql_fetch_array($sql)){
  if(isset($row['fname'])){
   mysql_query("INSERT INTO dispo_Money (Name, Phone, Email, Position, State, Comments) VALUES ('$row[fname] $row[lname]','$row[areacode]$row[prefix]$row[linenumber]','$row[email]','$row[position]','$row[state]','$comments')");
   // mysql_query("DELETE FROM contactinfo WHERE email='$row[email]'");
   redirect("http://www.xxxxxx.php");
  }
}
}

function redirect($filename="?", $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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.