Hello.
Complete newbie and I am trying to troubleshoot an existing redirect script for a client:
<?php
/*echo "file array<br><pre>";
print_r ($_POST);
echo "</pre>";
*/
/*************************************************************/
/* Resume : Redirect to another page or site */
/*************************************************************/
function tep_redirect($url) {
if ( (ENABLE_SSL == true) && (getenv('HTTPS') == 'on') ) { // loading an SSL page
if (substr($url, 0, strlen(HTTP_SERVER)) == HTTP_SERVER) { // NONSSL url
$url = HTTPS_SERVER . substr($url, strlen(HTTP_SERVER)); // Change it to SSL
}
}
header('Location: ' . $url);
exit;
}
if (!isset($_POST['username']) && $_POST['username'] != '') {
// returns to calling page if there is no username passed. Problem with Flash unless that is a stand alone flash movie on a separate page.
$red = $tep_redirect($HTTP_SERVER_VARS['HTTP_REFERER']);
}
else {
$error = '';
$filearray = file('****.txt') or die('File not read');
/* echo "file array<br><pre>";
print_r ($filearray);
echo "</pre>";
*/
for ($i = 0; $i < count($filearray); $i++) {
if (strpos($filearray[$i],$_POST['username']."\t") > -1) {
$userdata = explode(chr(9), $filearray[$i]);
$username = $userdata[0];
$password = $userdata[1];
$email = $userdata[2];
$path = $userdata[3];
$pathexploded = $path."/";
echo $username."<br>";
echo $password."<br>";
echo $email."<br>";
echo $path."<br>";
echo $pathexploded."<br>";
}
}
$byebye = tep_redirect($pathexploded);
}
?>
The echos are showing the correct values, but the page refuses to go to the new location. I even tried replacing at the top:
$url = HTTPS_SERVER . substr($url, strlen(HTTP_SERVER)); // Change it to SSL
}
}
header('Location: ' . $url);
exit;
with:
$url = "http://www.yahoo.com";
}
}
header('Location: ' . $url);
exit;
and it still doesn't want to relocate. I tried just a blank file with only a simple redirect straight to an outside location:
<?php
/**
* Place in a blank PHP page
*/
// Change to the URL you want to redirect to
$URL="http://www.yahoo.com";
header ("Location: $URL");
?>
and that is working fine. Any nudges in the right direction are greatly appreciated!!
Thanks!!