Jump to content

Password validation


watagal

Recommended Posts

Greetings-I'm using ajax technologies to validate my sign in form. Here's the js function my form calls on submit.

function validateSignIn(pageId) {	var userName = document.frmSignIn.txtUserName.value.toLowerCase();	var password = document.frmSignIn.txtPassword.value;	var validation = getAjaxQuery('validateSignIn.php?u='.userName.'&p='.password);		if (validation == "Invalid User Name") {		document.getElementById('divInvalidUserName').style.display = "block";		document.getElementById('txtUserName').value = ""	} else if (validation == "Invalid Password") {		document.getElementById('divInvalidPassword').style.display = "block";		document.getElementById('txtPassword').value = ""	} else {		// Redirect to index.php		window.location="index.php?p="+pageId;	}}

My question is "Is there a better way to pass the 'password' to my PHP file (for validation)? I feel my current implementation is poor security.TiA, Gal

Link to comment
Share on other sites

I figured out how to send my password data via POST! Yea!! thought I'd share it here for other noobs.I found how to do this in "Ajax for Dummies".

// AJAX callfunction ajaxCall(dataSource, method, encode, async) {	xmlHttp = createAjaxObject();	if (xmlHttp != null) {		xmlHttp.onreadystatechange = function() {			if ((xmlHttp.readyState == 4 || xmlHttp.readyState == "complete" ) && xmlHttp.status == 200) {				return xmlHttp.responseText;				}		}											if (method == "POST") {		xmlHttp.open("POST", dataSource, async);									xmlHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');									xmlHttp.send(encode+"&sid="+Math.random());											} else {					xmlHttp.open("GET", dataSource+"&sid="+Math.random(), async);									xmlHttp.send(null);		}	} else		alert ("Browser does not support HTTP Request");}

I'll call it in a JS script:

var validation = ajaxCall('php_code/validateSignIn.php',"POST",'u='+userName+'&p='+password, false);

I probably didn't ask my original question very well, but I appreiciate all thoses who took a stab at it. Thanks again, this site is great!--Gal

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...