Everything about the form works great, adds contacts, displays an error message if needed. (i'm using a stripped down version of the simple_form.php sample file)
But i don't know why the success message is showing up when the page is loaded. Before anyone has submitted the form.
Is wordpress doing something? If i run the php file separately, there is no issues with the success message. But when it's included in the rest of the wp templates it shows up again. Odd. Any ideas?
I have tested our PHP sample form in my own installation of wordpress, and have not run into the issue you are describing with the success message appearing before the form on simple_form.php is actually submitted. I have however seen some issues where Wordpress will not always inturpret PHP correctly if it is inserted into a page/post using certain plugins.
I successfully tested this using Wordpress version 2.9.2 along with the plugin 'Exec-PHP' which allows me to insert PHP directly into my pages/posts using the Wordpress editor, as long as the php code is contained within <phpcode> </phpcode> brackets.
With that being said, different versions of wordpress, modifications to simple_form.php, and use of different Wordpress plugins certainly have the potential to cause unexpected results. To continue to troubleshoot this, I would need a few pieces of information from you. You can either reply directly to this post or email our webservices support team with this information.
1. What version of Wordpress are you using?
2. What Plugins are you using in Wordpress?
3. What method are you using to insert simple_form.php into your Wordpress? Are you hard coding this into a specific page, or are you inserting php code directly into your pages/posts using the Wordpress WYSIWYG editor?
4. Please also post/attach your simple_form.php page so that I can see any modifications that have been made.
You may also want to take a look at this Wordpress Plugin, which is made to integrate some Constant Contact functinality into Wordpress. Please note that this is not created or supported by Constant Contact, but it may have some of the functionality you are looking to add.
Hi thanks for the response,
here's the code i've modified. https://dl.dropbox.com/u/949061/form.txt
The .php file is brought in via INCLUDE into the sidebar.php (in wordpress) which is then used through out the entire site.
It's the latest version of wp, 2.9.2, there are no plugins being used currently.
Everything works just great, except for the success message displaying prematurely :)
I set up my wordpress sidebar.php to include the simple_form.php that you had posted, and I was able to replicate the same error that you were recieving with the success message being displayed before the form was submitted. In addtion, when I ran simple_form.php on its own, the page worked correctly, and the error / success message was not displayed until the form was actually submitted.
I believe this error is being caused because $error is being set elsewhere in wordpress, therefore it is either displaying an error or a sucess message. If you change the variable used on simple_form.php from $error to something unique (ie: $cc_error), this should hide any message until the form is actually submitted.
I hope this information helps. Please let us know if you have any other questions. Thanks!
Ahh perfect that fixed it, simple and easy. Thank you very much David. Perhaps the sample files should be updated to something less generic?
As a note to anyone else that reads this, don't forget to update the $error in the cc_class.php file as well.