close ad
Install the LAtest Updates to Work with CC 2017 and CC 2018
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

error in contact form - can't work it out

Thread began 6/09/2010 8:40 am by CraigR | Last modified 6/09/2010 11:55 am by Jason Byrnes | 920 views | 6 replies |

CraigRBeta Tester

error in contact form - can't work it out

i have a standard contact form which i have used a number of times.

I have the form check for the 'submit' button being pressed, and then through a series of checks to ensure validation.

it seems to run ok, but in this particular instance, i am getting an error message, as though the form has already been submitted.

error reads "Sorry, there was a problem sending your message. Please try later" which shouldn't be tested for, until the form is posted

the problem seems to lie with my CSSMenuWriter menu.

when it isn't included, I dont get the error, when it is, I do.

by commenting out line 197, the error goes away, but otherwise, line 212 will run.

i have used the form with many other CSSMenuWriter menus without a problem

link to live form is

contact.php

form code is attached

Sign in to reply to this post

mustang_sally_85344510

Your code looks like you have put it in a paragraph and is a static comment..

Sign in to reply to this post

CraigRBeta Tester

Yes, you are right, the comment is static, bur I am trying to establish why it is appearing.

it should only appear if the form has been posted and the $mailsent variable has not been set

Sign in to reply to this post

Jason ByrnesWebAssist

using "if($_POST)" is not a very reliable way to check if the form was posted.

$_POST is a supper global that contains an array of the posted elements. it exists whether a form is posted or not. If a form was not posted, it's an empty array, but it still exists. "if($_POST)" will pretty much always return true.

as a test, put the following on a blank page:

php:
<?php echo($_POST); ?>



this will return:
Array


to test for a form post use "if($_SERVER["REQUEST_METHOD"] == "POST")" instead

so the elseif statement at line 210 becomes:

php:
elseif ($_SERVER["REQUEST_METHOD"] == "POST" && !$mailSent) {



If that doesn't help the issue, then please send a copy of the CSSMenuWriter/cssmw0/menu.php so I can examine the code.

Sign in to reply to this post

mustang_sally_85344510

This only posts before you actually send the email...

Maybe it has something to do with the captcha code for
$mailsent

If I intentionally type a error on your form I get the
the proper messages, however I do NOT get your:
"Sorry, there was a problem sending your message. Please try later."

Your code for the "Sorry, there was a problem sending your message. Please try later." is identically for $mailsent

<?php
}
elseif ($_POST && !$mailSent) {
?>
<p class="warning">Sorry, there was a problem sending your message. Please try later.</p>
<?php
}
elseif ($_POST && $mailSent) {
?>
<p><strong>Your message has been sent. Thank you for your feedback.</strong></p>

I don't see where this "Sorry.." is connected to anything

Sign in to reply to this post

CraigRBeta Tester

<?php
}
elseif ($_POST && !$mailSent) {
?>
<p class="warning">Sorry, there was a problem sending your message. Please try later.</p>
<?php
}
elseif ($_POST && $mailSent) {
?>
<p><strong>Your message has been sent. Thank you for your feedback.</strong></p>


the 2 elseif lines ARE different, the first has a ! in front.

thanks for replying, I think Jason has a solution.

Thanks for the reply Jason, FYI I first set this page up over a year ago using code from David Power's book.
I will make other changes to the if statements as needed.

Thanks again

Sign in to reply to this post

Jason ByrnesWebAssist

no worries, if your still having problems, let me know.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...