Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2005-07-18 19:55:54

brian.zerangue
Member
Registered: 2005-02-15
Posts: 62

zem_contact, Thank You Re-direct problems in PHP5

This is really weird. I updated to rc3 rev 520 and I had a modified zem_contact plugin. I made the modifications listed at
here and here —- the Wilshire’s re-direct modification.

And now all the sudden on PHP5 on my TextDrive account, the re-direct doesn’t work, but on PHP4 on my MediaTemple account it still works.

Can anyone help me with this. I’ve included WILSHIRE’S RE-DIRECT MODIFICATION BELOW

Rerouting to a thank you page is another mod I made to the plugin already. Just find the block that starts on line 61:

if ($r) {
$_POST = array();
$out .= $thanks;
$f = parse($form);
}

Change to

if ($r) {
$_POST = array();
header(“Location: /thankyou”);
}

Just change the location to where your thank you page is.

Offline

#2 2005-07-18 20:02:55

Sencer
Archived Developer
From: cgn, de
Registered: 2004-03-23
Posts: 1,803
Website

Re: zem_contact, Thank You Re-direct problems in PHP5

This may be unrelated to your problem, but Location headers should always have an absolute URI:
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.30

Offline

#3 2005-07-19 02:26:12

brian.zerangue
Member
Registered: 2005-02-15
Posts: 62

Re: zem_contact, Thank You Re-direct problems in PHP5

Thanks Sencer. I don’t know what to do.

I thought that “/thankyou” was an absolute path. Anyway, I put my domain name… “http://domainname.com/thankyou” in its place. When I save the plugin with the changes and browse to the contact form and submit it , it takes me to a 200 OK page. Where it says…

OK

The document has moved here.

There is a link on the word “here” and the link is to the thankyou page that it was supposed to redirect to.

The funny thing is that I ran the same code on a PHP4 and another PHP5 box and it runs fine. But on the PHP5 box that I’m on, it does what I listed above.

Does this sound like a server issue? Does anyone have any ideas?

FYI… I’m a designer and have little knowledge of PHP. Thanks for your patience.

Last edited by brian.zerangue (2005-07-19 13:03:52)

Offline

#4 2005-07-19 07:20:32

Sencer
Archived Developer
From: cgn, de
Registered: 2004-03-23
Posts: 1,803
Website

Re: zem_contact, Thank You Re-direct problems in PHP5

Not absolute path, absolute URI. Take a look at the link, there’s even an example there.

Location: http://www.mysite.com/thankyou.php

Offline

#5 2005-07-19 16:18:18

brian.zerangue
Member
Registered: 2005-02-15
Posts: 62

Re: zem_contact, Thank You Re-direct problems in PHP5

Still same problems on PHP5. I do the absolute URI, and it takes me to a 200 OK page. Where it says…

OK

The document has moved here.

There is a link on the word “here” and the link is to the thankyou page that it was supposed to redirect to.

The PHP4 server, I left pointing to “/thankyou” and it works perfectly fine.

Offline

#6 2005-07-19 16:19:51

brian.zerangue
Member
Registered: 2005-02-15
Posts: 62

Re: zem_contact, Thank You Re-direct problems in PHP5

Do you think this has anything to do with Changeset 512? This is where y’all noted “Add another 200 OK, apparently both calls are necessary to work cross-webservers and protocol versions.

I don’t know where to go on this. Sorry, I’m just not saavy with PHP.

Any ideas why this is behaving this way only in PHP5?

Thanks!

Last edited by brian.zerangue (2005-07-19 16:22:27)

Offline

#7 2005-07-20 08:00:20

brian.zerangue
Member
Registered: 2005-02-15
Posts: 62

Re: zem_contact, Thank You Re-direct problems in PHP5

Thanks to Sencer… the fix to my problem listed above has been found… since changeset 512, they added another 200 OK…

In the publish.php file, Sencer had me comment out “header(“Status: 200 OK”);” AND it immediately started to re-direct properly.

Thanks Sencer!!!

Last edited by brian.zerangue (2005-07-20 08:01:21)

Offline

#8 2005-07-20 08:07:23

Sencer
Archived Developer
From: cgn, de
Registered: 2004-03-23
Posts: 1,803
Website

Re: zem_contact, Thank You Re-direct problems in PHP5

You’re welcome. I also just looked at the modification you linked to, and it only uses the Location-header but doesn’t set any status codes. If before the line with header(“Location… you would paste the following line, I am confident it would also work:

header("HTTP/1.x 301 Moved Permanently");

Offline

#9 2005-07-20 08:33:46

brian.zerangue
Member
Registered: 2005-02-15
Posts: 62

Re: zem_contact, Thank You Re-direct problems in PHP5

same error as before…

i moved back to the original changeset 512 code

and in the plugin I added…
header(“HTTP/1.x 301 Moved Permanently”);
before the line with header(“Location…

AND it gives me the SAME error as before… goes to the 200 OK page again

Last edited by brian.zerangue (2005-07-20 08:35:05)

Offline

#10 2005-07-20 09:04:28

Sencer
Archived Developer
From: cgn, de
Registered: 2004-03-23
Posts: 1,803
Website

Re: zem_contact, Thank You Re-direct problems in PHP5

Well, if you are not tired yet here are two (well three) more variations, all to use in the plugin modification (change the line with Location according to what you have – and also try out the full url in location http://mysite/thankyou instead of the /thankyou one.):

<notextile><pre>
header(“HTTP/1.1 301 Moved Permanently”);
header(“Location: “.$url);
header(“Connection: close”);
</pre></notextile>

or if that fails:

<notextile><pre>
header(“Status: 301”);
header(“Location: “.$url);
header(“Connection: close”);
</pre></notextile>

and this is almost ridiculous, but you never know:

<notextile><pre>
header(“HTTP/1.1 301 Moved Permanently”);
header(“Status: 301”);
header(“Location: “.$url);
header(“Connection: close”);
</pre></notextile>

This should keep you busy for a while… :D

Last edited by Sencer (2005-08-13 10:21:23)

Offline

#11 2005-07-20 15:59:53

brian.zerangue
Member
Registered: 2005-02-15
Posts: 62

Re: zem_contact, Thank You Re-direct problems in PHP5

Sencer -

BOTH OF THESE WORKED

header(“Status: 301”);
header(“Location: “.$url);
header(“Connection: close”);

header(“HTTP/1.x 301 Moved Permanently”);
header(“Status: 301”);
header(“Location: “.$url);
header(“Connection: close”);

Which one would be best to use?

Last edited by brian.zerangue (2005-07-20 16:11:35)

Offline

#12 2005-07-20 16:23:48

Sencer
Archived Developer
From: cgn, de
Registered: 2004-03-23
Posts: 1,803
Website

Re: zem_contact, Thank You Re-direct problems in PHP5

Ah, great. Thanks for taking the time to try it all out. If both worked, it’s your choice. It doesn’t even hurt to put them both in there. (Some webservers are picky about what they choose to follow, but if your’s understands it all, even better).

Offline

Board footer

Powered by FluxBB