[PHP] How do I output error messages
Hi all, I have a web page that I am doing valildation on. I have figured out how to at least get the page to load the page content. What I can't seem to figure out is how to output the error messages to the screen. The validation is being performed on the same page as the form that is being validated. The way the page is setup: if (isset($submit)) { //vaildation code } else { //webpage } Thanks for the help, Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] How do I output error messages
[snip] if (isset($submit)) { //vaildation code } else { //webpage } [/snip] What is $submit? Is it set ever? The problem probably lies in the fact that $submit, whatever it is, never gets set. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] How do I output error messages
You could pass your error message back and forth as an HTTP post. $myMsg = $_GET['error_msg']; if(isset($myMsg)) { //print my message } else { //process as normal } -Original Message- From: Paul Goepfert [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 21, 2006 12:53 PM To: php-general@lists.php.net Subject: [PHP] How do I output error messages Hi all, I have a web page that I am doing valildation on. I have figured out how to at least get the page to load the page content. What I can't seem to figure out is how to output the error messages to the screen. The validation is being performed on the same page as the form that is being validated. The way the page is setup: if (isset($submit)) { //vaildation code } else { //webpage } Thanks for the help, Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How do I output error messages
On Tue, February 21, 2006 12:52 pm, Paul Goepfert wrote: $messages = array(); if (isset($submit)) { //vaildation code Each invalid input adds another element to $messages array. //E.G.: if (!isset($_REQUEST['name'])) $messages[] = Name is a required field.; } else { if (count($messages)){ echo p class=\error\, implode(br /\n, $messages), /p\n; } //webpage } You still need to take care that the //webpage itself is not made insensible by the error conditions... In extreme cases, such as the database being down and there being no hope of the rest of the page being useful, I sometimes will do: if (!$connection){ head(Error); //This prints out masthead/navbar etc $messages[] = Unable to access database. Please try later.; echo p class=\error\, implode(br /\n, $messages), /p\n; foot(); //This closes all HTML tags from head() //both head and foot are defined in a single include file, //making it trivial to match up HTML open/close tags } It's not as slick as some CRM setups, but it's also not as cumbersome and over-engineered (imho). DSFDF -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How do I output error messages
$submit is soppose to be set when the user submits the web form for validation. I am not sure but is there soppose to be a $submit = input type=submit name=submit value=submit statement? Paul On 2/21/06, Jay Blanchard [EMAIL PROTECTED] wrote: [snip] if (isset($submit)) { //vaildation code } else { //webpage } [/snip] What is $submit? Is it set ever? The problem probably lies in the fact that $submit, whatever it is, never gets set. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php