Hi guys!

This is a continuation post of my last thread regarding login with session..Now the main task is, the login form is now driven with Fancybox.. What i need to know is how to let the fancy box check/compare the value on mysql table if the username & password is the same on the table tbl_user_list. If the comparison is correct, it should display the user_page.php where the user full name from mysql table will be displayed on that page.

Here is the code of the div class containing the form.

<!-- MEMBERS LOGIN POPUP --> 
 
    <div class="style24" style="display:none">

	<form id="login_form" method="POST" action="" name="memlogin">
    
      <p id="login_error">Enter your User Name & Password...</p>
        
		
			<label for="login_name">Enter User Name: </label>
			<br><input type="text" id="login_name" name="login_name" size="40" /></br>
	 
        
		<p>
			<label for="login_pass">Enter Password: </label>
			<br><input type="password" id="login_pass" name="login_pass" size="40" /></br>
	  </p>
        
		<p>
			<input type="submit" value="Login" />
	   </p>
        
		<p>
		    <em>( Chat Admin to ask for User Name & Password )</em>	  </p>
	</form>
</div>

Here is the fancy box to call the div form..And i think i mess up something in this fancy box call function..

<script type="text/javascript">
$(document).ready(function() {
   $("#popup").fancybox({
        'scrolling'		: 'no',
	'titleShow'             : false,
	'transitionIn'          : 'elastic',
        'transitionOut'         : 'fade',
	'onClosed'		: function() {
	$("#login_error").hide();
	}
  });
 });
$("#login_form").bind("submit", function() {

	if ($("#login_name").val().length < 1 || $("#login_pass").val().length < 1) {
	    $("#login_error").show();
	    $.fancybox.resize();
	    return false;
	}

	$.fancybox.showActivity();

	$.ajax({
		type		: "POST",
		cache		: false,
		url		: "user_page.php",
		data		: $(this).serializeArray(),
		success		: function(data) {
				$.fancybox(data);
		}
	});

And here is the php query to hold the username, password, and fullname.

$username = @stripslashes($_POST['login_name']);
$password =@stripslashes($_POST['login_pass']);


mysql_select_db($database_nmpc_web_conn, $nmpc_web_conn);
$query_rec_mem_accnt = sprintf("SELECT user_name, password, member_id, fullname FROM tbl_user_list WHERE user_name = %s and password = %s", GetSQLValueString($username, "text"),GetSQLValueString($password, "text"));

$rec_mem_accnt = mysql_query($query_rec_mem_accnt, $nmpc_web_conn) or die(mysql_error());
$row_rec_mem_accnt = mysql_fetch_assoc($rec_mem_accnt);
$totalRows_rec_mem_accnt = mysql_num_rows($rec_mem_accnt);

Everything works fine except the fancy box to compare the value tom mysql and load the result on user_page.php page.

Im trying to do this myself but no luck..Pls help..

Thank you!

You'll have to do some logging: what does work, what doesn't? Do you get back the correct data? If so, are you sure $.fancybox can deal with that data? If not, how do you give it back anyway?

Yes I've done logging without fancy box and it works fine..Now the client ask to make it a login driven with fancy box...Ive just loaded the fancy box with the form div but the logging problem with fancy box is mess up.. I cant figure out how to compare it to mysl tbl_user_list.It should do something like this..

$("#login_form").bind("submit", function() {
 
if ($("#login_name").val()!= $rec_mem_accnt('username') && $("#login_pass").val()!=                 $rec_mem_accnt('password') {
     $("#login_error").show();
     $.fancybox.resize();
     return false;
	}
 
	$.fancybox.showActivity();
 
	$.ajax({
		type		: "POST",
		cache		: false,
		url		: "user_page.php",
		data		: $(this).serializeArray(),
		success		: function(data) {
				$.fancybox(data);
		}
	});

<this area should contain a code to pass the fullname of the login user to user_page.php>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.