Page 1 of 1

phpmailer headerredirect

Posted: Mon 31. Jul 2006, 19:00
by kac
Hi, I'm getting this error by some browsers:
Fatal error: Call to undefined function: headerredirect() in .../include/inc_act/act_formmailer.php on line 38
The mailer seems to work fine with most browsers. I wasn't even aware that there was a problem until someone told me about it. The person that showed me the error was using NS (unsure of the version) and I recreated the error with Omniweb5.01 and Opera 7.5 all for the Mac.

I'm using phpwcms v1.2.7


Any help is appreciated.

Posted: Tue 1. Aug 2006, 01:15
by DeXXus
Hmmm there is no function: headerredirect in phpWCMS. You will have to explain a little more about what sequence of actions (with the mailer) that bring up the error. Newsletter or email form? Does the -other- of those two produce same symptom, too?

Do you get a message like:
"The page cannot be refreshed without resending the information. Click Retry to send the information again, or click Cancel to return to the page that you were trying to view."

It may be that PHP has trouble setting it's SERVER variable --> $_SERVER['HTTP_REFERER'] <--from those browsers, to determine if submittal is from within your site (security measure)? Is the browser being refreshed prematurely? Maybe turning on all errors, warnings and notices in "php.ini" will show more?

Line 38 is:

Code: Select all

header('Location: '.$phpwcms["site"].$phpwcms["root"]);
IN

Code: Select all

// Only internal form sender allowed
require_once ("../../config/phpwcms/conf.inc.php");

//$NO_DB_CONNECT = true;

$url = $phpwcms["site"];
$url = str_replace('http://', '', $url);
$url = str_replace('https://', '', $url);
$url = preg_replace('/\/$/', '', $url);
$ref = $_SERVER['HTTP_REFERER'];
$ref = str_replace('http://', '', $ref);
$ref = str_replace('https://', '', $ref);
if( strpos($ref, $url) === false) {
	header('Location: '.$phpwcms["site"].$phpwcms["root"]);
	exit();
}

Posted: Tue 1. Aug 2006, 04:26
by kac
Hi, it's in the act_formmailer, line 38, headerRedirect($phpwcms["site"].$phpwcms["root"]);

That's the one that the error is coming from, but there are several others in the act_formmailer.php script.

I am using the old email form generator, is that the problem?

thanks

Posted: Tue 1. Aug 2006, 04:41
by DeXXus
kac wrote:Hi, it's in the act_formmailer, line 38, headerRedirect($phpwcms["site"].$phpwcms["root"]);

That's the one that the error is coming from, but there are several others in the act_formmailer.php script.

I am using the old email form generator, is that the problem?

thanks
Must be something like that, because the "pristine" archive of pre1.2.7_phpwcms includes what I have described:
in "act_formmailer.php"
header('Location... instead of headerRedirect(...

If that function, headerRedirect() is being called... then the file where that original function is "defined"... must be included with a PHP statement!

Posted: Tue 1. Aug 2006, 06:49
by kac
hi,

The difference in act_formmailer.php was I hadn't installed the patch, now my formmailer is like yours.

Installing the patch also fixed the Omni browser getting the error, but Opera still has problems. After hitting submit the page refreshes to the home page without the "Thank you" page, and no e-mail is received. There is something else with Opera too, it's loading my pages in a different language-- but only this one site every other site seems to be fine. Since this appears to be an Opera problem I'm considering the e-mail problem fixed.

Thanks for your help

Ken

Posted: Tue 1. Aug 2006, 08:38
by pico
Hi

just for your Information:

function headerRedirect() is defined in general.inc.php -
and is used serval times

Code: Select all

function headerRedirect($target='') {
	header('Location: '.$target);
	if(isset($_SESSION)) {
		session_write_close();
	}
	exit();
}
have also sometimes on one Server !? a Warning after sending from (new) Contact Form
Warning: Header may not contain more than a single header, new line detected. in /home/chs/efectored.com/home/html/include/inc_lib/general.inc.php on line 1164
this are the two Points in cnt23.article.inc.php

Code: Select all

if($cnt_form["onerror_redirect"]) {

		headerRedirect(str_replace('{SITE}', PHPWCMS_URL, $cnt_form["onerror"]));
or

Code: Select all

		if(!$mail->Send()) {
			$CNT_TMP .= '<p>'.html_specialchars($mail->ErrorInfo).'</p>';
		} elseif($cnt_form["onsuccess_redirect"]) {
			// redirect on success
			headerRedirect(str_replace('{SITE}', PHPWCMS_URL, $cnt_form["onsuccess"]));
		} elseif($cnt_form["onsuccess"]) {
have tried to reproduce this, but as I said - it not happen at every Server (they are almost with the same Configuration Apache, PHP, mySQL) and at the one where it happens, I cannot run a Debugger.
The Mail is send anyway.

Posted: Tue 1. Aug 2006, 16:02
by kac
In case anyone else is paying attention to this problem here's an update.

After installing the patch the contact form worked for most browsers, but I found out that I couldn't log in to the admin. I got the same redirect error but coming from login.php.

This forced me to remove the patch and go back to the original if I wanted to be able to update my site.



thanks