0

I want this javascript to directly compare the username and password of the user who login to mysql table that holds all the registered username and password..

<script type="text/javascript">

$("#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		: "members_accnt.php",
		data		: $(this).serializeArray(),
		success		: function(data) {
				$.fancybox(data);
		}
	});

	return false;
});

 </script>

Thank you for helping!

Edited by blocker: n/a

4
Contributors
5
Replies
6
Views
6 Years
Discussion Span
Last Post by blocker
0

You might get a better reply posting this in the javascript/DHTML/ajax forum.

Edited by iamthwee: n/a

0

You might get a better reply posting this in the javascript/DHTML/ajax forum.

Ive decided to post here in php forum because i use php to access the mysql table that holds the registered username and password.

here it is..

if (isset($_POST['login_name'])){

$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 FROM tbl_members_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);

Now, is it possible to compare this query in javascript above?

Thank you!

0

My take:

if (isset($_POST['login_name']) && isset($_POST['login_pass'])){
 
	$u = mysql_real_escape_string($_POST['login_name']);
	$p = mysql_real_escape_string($_POST['login_pass']);
	 
	mysql_select_db($database_nmpc_web_conn, $nmpc_web_conn); //?from where??
	
	$r = mysql_query("SELECT user_name, password, member_id FROM tbl_members_list WHERE user_name = '$u' and password = '$p'") or die(mysql_error());
	$t = mysql_num_rows($r);
	if($t > 0){
		$d = mysql_fetch_assoc($r);
	}else{
		...
	}
	...
}

BTW - why sprintf? I know what it does/how it works, but what advantage does it give you? Just curious.

0

Ive decided to post here in php forum because i use php to access the mysql table that holds the registered username and password.

Ajax is how most, allow javascript, clientside, to interact with php, on the server, where JavaScript does not operate with much efficacy.
so why not,
given that you have not written a new language construct to release to the world,
repost the question in the language forum devoted to allowing Javascript to interact with php/sql

2 bricks

Edited by almostbob: n/a

0

Ive got the solution..just put this ' before and after php tag...it seems that javascript reads the value as a variable!This is good if security issue is not the concern.

Thanks also to ardav for a nice take..

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.