From: Kim on 18 Feb 2007 10:40 Hi, I've this in my source: echo '<p class="required">'."\n"; if ($HTTP_SERVER_VARS['REQUEST_METHOD'] == 'POST'){ print $validator->getError(); } if ($HTTP_SERVER_VARS['REQUEST_METHOD'] == 'POST' && !checkAnswer()){ print "The spamtrap question was not answered correctly!<br />"; } if ($HTTP_SERVER_VARS['REQUEST_METHOD'] == 'POST'){ print $validator->getErrorText(); } echo '</p>'."\n"; and as you can see I print out the <p> tags to have a container for the error msg. The problem is now that I'm using a background image in the <p class="required"> block and since I print out the <p> tags no matter what you can see part of the "error block" if there are errors or not. (I just get an empty <p></p> if no errors... not good! So I need another way where I don't print out the <p> tags unless I need them. Any ideas? -- Kim --------------------------- http://www.geekministry.com
From: David Powers on 18 Feb 2007 14:19 Kim wrote: > So I need another way where I don't print out the <p> tags unless I need > them. $error = false; $spam = false; if ($_SERVER['REQUEST_METHOD'] == 'POST' && $validator->getError()){ $error = true; } if ($_SERVER['REQUEST_METHOD'] == 'POST' && !checkAnswer()){ $spam = true; } if ($_SERVER['REQUEST_METHOD'] == 'POST' && $validator->getErrorText()){ $error = true; } if ($error || $spam) { // print out all your messages } -- David Powers, Adobe Community Expert Author, "Foundation PHP for Dreamweaver 8" (friends of ED) Author, "PHP Solutions" (friends of ED) http://foundationphp.com/
From: Kim on 18 Feb 2007 14:50 Hi David, Thanks for your reply. I just found a solution and I was thinking way to complicated. Thanks a lot for your soluion. <?php if ($HTTP_SERVER_VARS['REQUEST_METHOD'] == 'POST'){ echo '<p class="required">'."\n"; print $validator->getError(); if(!checkAnswer()){ print "The spamtrap question was not answered correctly!<br />"; } print $validator->getErrorText(); echo '</p>'."\n"; David Powers skrev: > Kim wrote: >> So I need another way where I don't print out the <p> tags unless I >> need them. > > $error = false; > $spam = false; > > if ($_SERVER['REQUEST_METHOD'] == 'POST' && $validator->getError()){ > $error = true; > } > if ($_SERVER['REQUEST_METHOD'] == 'POST' && !checkAnswer()){ > $spam = true; > } > if ($_SERVER['REQUEST_METHOD'] == 'POST' && $validator->getErrorText()){ > $error = true; > } > > if ($error || $spam) { > // print out all your messages > } > -- Kim --------------------------- http://www.geekministry.com
|
Pages: 1 Prev: Pasting table again--not enough cells Next: Sharing Violation with a .dwt file |