Jump to content

login form inside the main form


runjel

Recommended Posts

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?..

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.