Sunday, 15 September 2013

html - Styling PHP errors or messages from a separate file -



html - Styling PHP errors or messages from a separate file -

i have simple login form , separate php file contain error message functions etc (i.e. "password field empty" etc).

the problem when error triggered form not style error message same form. error appears unformatted @ bottom of page.

i want able apply forms css php messages in separate file.

this code snippet separate php file:

// check login form contents if (empty($_post['user_name'])) { $this->errors[] = "username field empty."; } elseif (empty($_post['user_password'])) { $this->errors[] = "password field empty.";

i want able place these error message within div elements of form. @ nowadays end unformatted @ bottom of page.

i have tried enclosing php in separate file in same div tags form has not work.

hope makes sense.

any advice appreciated.

just create custom config file

config.php

$_session['err_uname_req'] = "<font color='red'>username required</font>"; $_session['err_pword_req'] = "<font color='red'>password required</font>"; ...

in sample form:

session_start(); //call config.php if($_post['username'] == "")//or approach display error { echo $_session['err_username_req']; }

php html css formatting

No comments:

Post a Comment