pappakaka Posted February 7, 2011 Share Posted February 7, 2011 I have finally gotten my registration form to work on my website but i have another question! When for example someone registers at my website and type in the wrong email address, i've set php to give out an error message like "Please enter a valid email address". But that message shows up at the verry top-left corner of my page and makes some objekts move around on my page and you can't click in the <input> fields anymore . How could i make those error messages show up above my registration form at the top of my site and maybe style them with a border and maybe make the text red and so that it doesnt change anything on my page? could i use css for that somehow or what? This is how i show the error messages right now: public function show_errors() { echo "<h3>Errors</h3>"; foreach($this->errors as $key=>$value) echo $value."<br>"; } public function valid_data() { if($this->user_exists()) $this->errors[] = 'Username already taken, choose another one!'; if(empty($this->username)) $this->errors[] = 'Please enter a valid username!'; if(empty($this->first_name)) Quote Link to comment https://forums.phpfreaks.com/topic/226917-how-do-i-style-and-position-the-error-messages-my-php-code-gives-out-on-my-page/ Share on other sites More sharing options...
litebearer Posted February 7, 2011 Share Posted February 7, 2011 Random thoughts.. 1. if you have a blank area on your form large enough to hold all possible error messages, you could have an IF statement, where if error then show div else don' show div 2. you could have an if statement next to or under each field, where if error show else don't 3. you could have an if statement, where if error ONLY the error fields are shown - may need to place good filed values in hidden fields or session variables. Quote Link to comment https://forums.phpfreaks.com/topic/226917-how-do-i-style-and-position-the-error-messages-my-php-code-gives-out-on-my-page/#findComment-1170849 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.