Author Topic: Trouble With Forms  (Read 1142 times)

k52412

  • Newbie
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Trouble With Forms
« on: July 29, 2009, 12:07:34 AM »
I just updated my current site to version 1.3.2 and now my forms are not working correctly.  The form itself is going throught the motion, but then I get an error message "No recipient addresses found in header".  Is there something in the new version that would be causing my headers to not repost to the form?  Thanks for your help. :)

Xander

  • Developer
  • Administrator
  • Full Member
  • *****
  • Posts: 240
  • Karma: +5/-0
    • View Profile
    • CompactCMS.nl
Re: Trouble With Forms
« Reply #1 on: July 29, 2009, 01:59:16 AM »
Hi!

Actually I'm not really sure what you mean by the error "no recipient addresses found in header". This sounds like a PHP mail() function error and CompactCMS isn't using that function... Perhaps you refer to your own page that stopped working, in which case we might be able to help, but a link or a reference to the original source will help.

If you do use a PHP mail() function somewhere, be sure to mark that page to contain coding (a new variable added after the printable and active options).

Cheers,
Xander.
« Last Edit: July 29, 2009, 02:35:37 AM by Xander »
Don't ever hold back your suggestions. Help me either to improve CompactCMS or spread the word about it on sites such as Twitter, Digg, StumbleUpon, etc :). Thanks!

k52412

  • Newbie
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Trouble With Forms
« Reply #2 on: July 29, 2009, 03:23:45 AM »
Thank you for your help and great program.  After a little more thought I checked just the php content and the form works properly , but when you go through the cms system it gives the error.

here is the link when its working correctly.

http://www.englewoodlock.com/compact/content/contact.php

and here is the link when its not working:

http://www.englewoodlock.com/compact/contact.html

Thank you for your help.  I'm attaching the code in a text file.




Xander

  • Developer
  • Administrator
  • Full Member
  • *****
  • Posts: 240
  • Karma: +5/-0
    • View Profile
    • CompactCMS.nl
Re: Trouble With Forms
« Reply #3 on: July 29, 2009, 03:00:37 PM »
That might be the most extensive PHP code I've ever soon for submitting a form :). The problem lies - I think - in the fact that your posting to the so called:

<? echo $HTTP_SERVER_VARS['PHP_SELF']; ?>

variable. This format isn't supported by recent versions of PHP. Instead it should be:

<? echo $_SERVER['PHP_SELF']; ?>

We can see that your server isn't supported the old format, because when you look to the source, the action for form is empty. An empty action="" automatically posts to the current page.

* In the non templated view this works, because the current page (contact.php) is the page with the send code (contact.php).
* The templates view doesn't work because the current page (index.php?page=contact) is not the page with the send code (contact.php).

So there appears to be your error. Try changing the form action to action="index.php?page=contact" or perhaps action="./content/contact.php".

I'm considering making a default form script using Mootools with a tutorial on how to implement in CCMS. If that's appreciated, I'll post here once done.

Xander.
Don't ever hold back your suggestions. Help me either to improve CompactCMS or spread the word about it on sites such as Twitter, Digg, StumbleUpon, etc :). Thanks!

k52412

  • Newbie
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Trouble With Forms
« Reply #4 on: July 29, 2009, 10:27:18 PM »
I cannot get it to work changing out variable $http_server,  the only way I can get it to work is using

action="./content/contact.php"

But when using this I loose all of the rest of thepage and the only thing that remains is the form itself.  This form worked before I updated is there anything in the update that might have caused this form to stop working?  Thank you for all of your help and quick responses.

Xander

  • Developer
  • Administrator
  • Full Member
  • *****
  • Posts: 240
  • Karma: +5/-0
    • View Profile
    • CompactCMS.nl
Re: Trouble With Forms
« Reply #5 on: July 29, 2009, 10:48:27 PM »
That is actually what suprises me most. It used to work, and now it doesn't. I implemented a new way of showing pages for when no coding was included (with Wiki markdown support), but by setting the page to contain coding the old function should be used.

Gives me something to go through though ;). Perhaps the Wiki markdown solution hasn't been a good one. In the mean time I could suggest to you to create a new page (thankyou.html) and set your current "thank you" after posting text there. Then in your contact script you could change the display_thankyou() function to refer to the new thankyou.html.


<?
function 
display_thankyou() {
   
header("Location: /thankyou.html");
   exit();
?>


This would cause your script to redirect the page to thankyou.html as soon as the thank you function is called. I admit this isn't the best solution, since it requires you to adapt programming, but it might just work.

I'm sorry for the trouble 1.3.2 is causing you. If you ever look for an older version, refer to the archive.

Cheers,
Xander.

P.s.: I'll try to simulate your problem here locally to see whether I can find the cause of it.
Don't ever hold back your suggestions. Help me either to improve CompactCMS or spread the word about it on sites such as Twitter, Digg, StumbleUpon, etc :). Thanks!

k52412

  • Newbie
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Trouble With Forms
« Reply #6 on: July 29, 2009, 10:55:31 PM »
I really appreciate all your help.  If I find the solution or if there is anything I can provide you with that might help just let me know.

Thanks

Xander

  • Developer
  • Administrator
  • Full Member
  • *****
  • Posts: 240
  • Karma: +5/-0
    • View Profile
    • CompactCMS.nl
Re: Trouble With Forms
« Reply #7 on: July 30, 2009, 12:55:53 AM »
Okay, I've played with functions in the CCMS environment to see what is holding your form back from being posted. I noticed that when I set the action="contact.html" that my custom function (not mail) does work. Here is what I've done, which perhaps you could test as well.

contact.php

<?
// Only run when contact.html is posted to
if($_SERVER['REQUEST_METHOD']=='POST') { 

// Just to test the functionality of a custom function
function sum($var) {
	
$result $var+3+2;
	
return 
$result;
}

	
// Call to custom function. Check whether posted number + 3 + 2 >10
	
if(
sum($_POST['number'])>'10') {
	
    
// If >10 then echo:
	
    echo 
"Sum is larger than 10!";
	
} else die(
"Error: smaller than/or equal to 10");
}
?>

<div class="clear">
<form action="contact.html" method="POST" accept-charset="utf-8">
	

	
<fieldset id="contact_form" class="">

	
	
<label for="number">Number</label>
	
	
<input type="input" name="number" value="" id="number" class="text" />
	

	
	
<p class="prepend-7"><button type="submit">Calculate &rarr;</button></p>
	
</fieldset>
</form>
</div>


If I test this locally in the CCMS environment I first get the input field. If I enter 3 and hit calculate I get the message that the sum < 10. If I enter 6 then the sum > 10. It's no rocket science of course, but it shows that the function is working.

Then when I copy - paste your contact script (and change the config) + set the action="contact.html" I first get the expected screen (without CSS of course, haven't copied that). Submitting an empty form gives errors for name and e-mail. Once I fill those out, the form gets submitted and gives the thank you message with an error which entails the face that my localhost doesn't have a mail server configured (which is true). But most importantly: it gives these errors within the wrapper of the CCMS template.

So I can't seem to reproduce your error. Perhaps I could take a look at your administration (PM with the credentials) or perhaps only changing the action="contact.html" already helps you. I've gone through the *.diff for 1.3.1 and 1.3.2 and both use (when coding is set to Yes) include_once('./content/$page);, so it seems that the new version couldn't cause this. Still I recognize that something is causing this, so perhaps we're missing out a very obvious setting :). Wouldn't be the first time ;).

Cheers,
Xander.

P.s.: I've just written this tutorial. Feel free to test it and see whether it might work for you.
« Last Edit: July 30, 2009, 01:55:35 AM by Xander »
Don't ever hold back your suggestions. Help me either to improve CompactCMS or spread the word about it on sites such as Twitter, Digg, StumbleUpon, etc :). Thanks!

Xander

  • Developer
  • Administrator
  • Full Member
  • *****
  • Posts: 240
  • Karma: +5/-0
    • View Profile
    • CompactCMS.nl
Re: Trouble With Forms
« Reply #8 on: July 30, 2009, 01:38:44 PM »
I'm intrigued :)... The only thing there was left for me to do, was to post the exact same script as you provided online. I've done this in the demo (here). I've created a contact page using the admin, then replaced the generated contact.php with your file (changing the e-mail addresses). It seemed to work and did sent the e-mail to my inbox. But it contained none of the values I entered :(. So I went through the script and saw (I think) some irregularities. I changed some $_values[] with $_POST[] and then checked again. That worked and I've sent you an e-mail using the form (all form submission by the way now go to you).

So normally I would now go off blaming your host (::))), but I've seen the error myself and can't ignore the fact that it used to work. On the other hand my example proves that it could work on an identical CCMS installation (1.3.2). The only thing there is left for me to do therefore is to advice you to try another form solution (e.g. the one I posted last night). I recon that this would require you to do some modifications, but I believe that the script might just be the problem (it uses plenty of obsolete coding).

You could at least try the form solution above (call it test.php) and see whether it works before actually investing time into modifying it.

Sorry I can't be of any further help, but right now I think I've done everything to test your situation.

Cheers!
Xander.
Don't ever hold back your suggestions. Help me either to improve CompactCMS or spread the word about it on sites such as Twitter, Digg, StumbleUpon, etc :). Thanks!