Jump to content

login form inside the main form


runjel

Recommended Posts

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.