Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > Web Development
You last visited: Today at 22:56

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Echo with div stays perm

Discussion on Echo with div stays perm within the Web Development forum part of the Coders Den category.

Reply
 
Old   #1
Trade Restricted
 
elite*gold: LOCKED
Join Date: Oct 2016
Posts: 321
Received Thanks: 79
Lightbulb Echo with div stays perm

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.
Underfisk is offline  
Old 04/08/2017, 15:05   #2
dotCom
 
Devsome's Avatar
 
elite*gold: 9842
The Black Market: 107/0/0
Join Date: Mar 2009
Posts: 16,841
Received Thanks: 4,675
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.
Devsome is offline  
Old 04/08/2017, 16:13   #3
Trade Restricted
 
elite*gold: LOCKED
Join Date: Oct 2016
Posts: 321
Received Thanks: 79
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
Underfisk is offline  
Old 04/08/2017, 17:15   #4
 
elite*gold: 100
Join Date: Apr 2008
Posts: 860
Received Thanks: 1,487
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:
florian0 is offline  
Old 04/08/2017, 18:29   #5
Trade Restricted
 
elite*gold: LOCKED
Join Date: Oct 2016
Posts: 321
Received Thanks: 79
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
Underfisk is offline  
Old 04/10/2017, 01:00   #6
Trade Restricted
 
elite*gold: LOCKED
Join Date: Oct 2016
Posts: 321
Received Thanks: 79
#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.
Underfisk is offline  
Thanks
1 User
Reply




All times are GMT +1. The time now is 22:57.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.