runjel Posted June 6, 2010 Share Posted June 6, 2010 hello nooobie here.. the problem is that i have a log in form which is inside the my main form.. i can log in without problem with the login form.. the thing is want to my show a new div whenever i log in and whenever i log out that new div will disappear... is that cookies?.. Quote Link to comment https://forums.phpfreaks.com/topic/204017-login-form-inside-the-main-form/ Share on other sites More sharing options...
dabaR Posted June 6, 2010 Share Posted June 6, 2010 You mean like a "Welcome dabaR" div? Unless you are doing AJAX, you would in your PHP have a if ($logged_in) { show_div(); } Quote Link to comment https://forums.phpfreaks.com/topic/204017-login-form-inside-the-main-form/#findComment-1068548 Share on other sites More sharing options...
runjel Posted June 6, 2010 Author Share Posted June 6, 2010 You mean like a "Welcome dabaR" div? Unless you are doing AJAX, you would in your PHP have a if ($logged_in) { show_div(); } yup like that but in my case i will show the control panel.. AJAX? can i use it with jquery?.. can you show me a sample code if its ok to you thanks Quote Link to comment https://forums.phpfreaks.com/topic/204017-login-form-inside-the-main-form/#findComment-1068561 Share on other sites More sharing options...
dabaR Posted June 6, 2010 Share Posted June 6, 2010 This guy wrote it already. This is only if you want to use AJAX for your form, which I am pretty sure you don't since it will increase complexity. Just make it work, then make it fancy later. http://www.developertutorials.com/tutorials/ajax/getting-started-with-ajax-in-jquery-8-05-11/page1.html There are also page2, page3, 4, 5 of that tutorial, linked in the "Tutorial pages" section Quote Link to comment https://forums.phpfreaks.com/topic/204017-login-form-inside-the-main-form/#findComment-1068563 Share on other sites More sharing options...
runjel Posted June 6, 2010 Author Share Posted June 6, 2010 thanks for that.. how about if i will use it with a database?... i want to hide it after i click logged out Quote Link to comment https://forums.phpfreaks.com/topic/204017-login-form-inside-the-main-form/#findComment-1068577 Share on other sites More sharing options...
dabaR Posted June 6, 2010 Share Posted June 6, 2010 Whether you use a database or not, this part is the same. Please give me a scenario of how it would work with as many details as you can. Quote Link to comment https://forums.phpfreaks.com/topic/204017-login-form-inside-the-main-form/#findComment-1068595 Share on other sites More sharing options...
runjel Posted June 6, 2010 Author Share Posted June 6, 2010 hmm how will i start.. in my main page we can find the login form... that login form is made up of div... after i successfully logged in that login form div will become hidden then my other hidden div which is the control panel will appear.. that control panel will include the account details of the one who logged in.. $(document).ready(function() { $("#login_form").submit(function() { var unameval = $("#username").val(); var pwordval = $("#password").val(); $.cookie('username', username, { expires: 14 }); $.post("backend.php", { username: unameval, password: pwordval }, function(data) { $("#status p").html(data); }); return false; }); }); function ShowLoginBox(){ userName = $.cookie('username'); if (userName != null && userName.length > 0) { $("#headerlogin").show(); $("#headerlogin2").hide(); } else { $("#headerlogin).hide(); $("#headerlogin2").show(); } } ShowLoginBox(); you see the data will be throw to the backend.php .. after it throw the data i dont what to do hehe.. do i need to make a cookie? thanks Quote Link to comment https://forums.phpfreaks.com/topic/204017-login-form-inside-the-main-form/#findComment-1068600 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.