Echo with div stays perm

04/08/2017 12:47 Underfisk#1
Hi, i'm coding a new platform in codeigniter and recently i'm trying to echo the errors message or sucess message with echo, but when i echo with div class i need to put the code +/- where i want the event to be showed.
Another thing is when it gives some error or sucess, as i echo a div (it assumes the div to the temporary code) and if i refresh it still stays there.

Here's the part of code im trying to echo:
PHP Code:
echo '<div class="page-alert sucess"><strong>Awesome!</strong> your account has been created successfully!<br></div>'
And this part of code is behind the form to show behind as i wanted to.
04/08/2017 15:05 Devsome#2
We need more code.

You can create a
PHP Code:
if else 
So when the $var with the Success or Error is filled you can return the echo.
04/08/2017 16:13 Underfisk#3
PHP Code:
            if(empty($accname) || empty($accpass1) || empty($accpass2)|| empty($accname) || empty($accmail)) { 
                echo 
"<div class=\"page-alert error\"><strong>Please fill all the fields!</div>";
            } elseif(
$row1 '0') { 
                echo 
"<div class=\"page-alert error\"><strong>Account name already exists</div>"
Thats the previous code before in a if an the else if is sucessfull is this one
PHP Code:
                mssql_query("INSERT INTO account.dbo.USER_PROFILE (user_no,user_id,user_pwd,resident_no,user_type,login_flag,login_tag,ipt_time,login_time,logout_time,user_ip_addr,server_id) VALUES ('$dk_user_no','".$accname."','".$accpass."','801011000000','1','0','Y','".date("Y-m-d H:i:s")."',null,null,null,'000')",$con); 
                echo 
'<div class="page-alert sucess"><strong>Awesome!</strong> your account has been created successfully!<br></div>'
PS: The code itself works, i can see the message in the div etc, and if is error or sucessfull it changes according to my css color etc. The problem is when the user refreh page after an error, the div of error still stays there, only if he moves to another page and comes back to register, thats the only way for it dissapear :(

Im kinda new at php
04/08/2017 17:15 florian0#4
Modern Web-Frameworks are usually MVC-driven, meaning PHP-Code-Logic and Visual-Logic is entirely separated.

Perform all your business logic (creating user, etc) in the Controller and the Model, and put the error message printing into the View:
[Only registered and activated users can see links. Click Here To Register...]
04/08/2017 18:29 Underfisk#5
I know how MVC works, im using controller to make my configs at loading of the page, and this verifications are in the view part but i cant figure out this part
04/10/2017 01:00 Underfisk#6
#Fixed
Solution : I've been reading up codeigniter manual and some guides, and i found why it keeps perm like there. This stuff was like a session , it keeps there until being destroyed if we echo the whole time a div.
Basicly i've put the div already there in php code and it awaits a msg code (of error) to show on and it keeps the code more clean either.