Jump to content

Problem with this script and IE


lewis987

Recommended Posts

Aight, i coded up a shoutbox with ajax (maybe dhtml aswell) and php, myself... no prototype crap... but it intergates a register system. And its the register javascript thats not working for me. Pretty much the whole thing is AJAX and works in Safari, Opera, and firefox (i hope it works in firefox anyway). But, back to the subject, when i attempt to register in IE, it fails, Something about "Member not found", I dunno how this works, but every other browser works fine. so here is the scripts:

 

Register.php (gets included with php hence the if defined):

<?PHP
if(defined("SCRIPT")){
		//Generate random string:
		$CHARS = array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z');

		$LIMIT = 6;

		for($i = 0; $i <= $LIMIT; $i++){
			$RAND = rand(0, count($CHARS));
			$SECURITY .= $CHARS[$RAND];
			$SECURITY2 .= $CHARS[$RAND]." ";
		}
	?>
	<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
	<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>Register</title>
		<script language="javascript" type="text/javascript" src="script2.js">
		</script>
	</head>

	<body>
	<div id="body">
	<h2>Register to _drw_shoutbox</h2><br />
	<br />
	<br />
	<form action="?act=reg" method="post" onsubmit="reg(document.getElementById('usr').value, document.getElementById('usrsucc').value, document.getElementById('pwd').value, document.getElementById('pwdsucc').value, document.getElementById('codesucc').value)">
		<div id="usrname">
			Username:<br />
			<input name="usr" type="text" onkeyup="regUsername(this.value)" id="usr" size="20" maxlength="35" />
		</div>
		<div id="usrname2">
		</div>
		<input type="hidden" id="usrsucc" value="2" />
		<br />
		<div id="password">
			Password:<br />
			<input name="pwd" type="password" onkeyup="regPassword(this.value)" id="pwd" size="20" maxlength="35" />
		</div>
		<div id="password2">
		</div>
		<input type="hidden" id="pwdsucc" value="2" />
		<br />

		<!-- Security stuff here -->
		<div id="sec1" style="width: 400px;">
			Security Code:<br />
			Enter: " <?PHP echo $SECURITY2; ?> " into the box below <br />
			(without the spaces and quotes):<br />
			<input type="text" name="secur" onkeyup="security(this.value ,'<?PHP echo $SECURITY ?>')" size="20" maxlength="<?PHP echo $LIMIT * 2; ?>" />
		</div>
		<div id="sec2">
		</div>
		<input type="hidden" id="codesucc" value="2" />
		<br />
			<input name="regi" id="regi" type="button" value="Register" onclick="reg(document.getElementById('usr').value, document.getElementById('usrsucc').value, document.getElementById('pwd').value, document.getElementById('pwdsucc').value, document.getElementById('codesucc').value);" />
	</form>
	</div>
	</body>
	</html>
    <?PHP
}else{
	echo "Error";
}
?>

 

script2.js (the trouble):


// JavaScript Document
function createRequestObject() {
var xmlHttp;
var work;
try
{
	work2 = 'Internet Explorer';
	xmlReq = new ActiveXObject("Msxml2.XMLHTTP");
	work = 1;
}
catch (e)
	{
	try
	{
		xmlReq = new ActiveXObject("Microsoft.XMLHTTP");
		work = 1;
	}
	catch (e)
	{
		try
		{
			work2 = 'Firefox, Opera 8.0+, Safari';
			xmlReq = new XMLHttpRequest();
			work = 1;
		}
		catch (e)
		{
	  		work = 2;
	  	}
	}
}
  if(work == 1){
		return xmlReq;
  }else{
	  
	   alert("Your browser does not support AJAX!");
  }
}
     
// Set all variables here
var http = createRequestObject();

function regUsername(username){
	http.onreadystatechange = function(){
		if(http.readyState == 4 && http.status == 200){  
			var response = http.responseText;
			if(response) {  
				if(response == 1){

				}else if(response == 2){
					document.getElementById('usrsucc').value = 1;
					document.getElementById('usrname').style = 'background-color: #afa; border-top: #0f0 thin solid; width: 400px; border-left: #0f0 thin solid; width: 400px; border-right: #0f0 thin solid; width: 400px;';
					document.getElementById('usrname2').innerHTML = 'Username: "'+username+'" is avaiable!';
					document.getElementById('usrname2').style = 'background-color: #afa; border-bottom: #0f0 thin solid; width: 400px; border-left: #0f0 thin solid; width: 400px; border-right: #0f0 thin solid; width: 400px;'
				}else{




					document.getElementById('usrname').style = 'background-color: #faa; border-top: #f00 thin solid; width: 400px; border-left: #f00 thin solid; width: 400px; border-right: #f00 thin solid; width: 400px;';



					if(response == 3){
						document.getElementById('usrsucc').value = 2;
						document.getElementById('usrname2').innerHTML = 'Username: "'+username+'" isn\'t avaiable!';
						document.getElementById('usrname2').style = 'background-color: #faa; border-bottom: #f00 thin solid; width: 400px; border-left: #f00 thin solid; width: 400px; border-right: #f00 thin solid; width: 400px;';
					}else{
						document.getElementById('usrsucc').value = 2;
						document.getElementById('usrname2').innerHTML = 'Username: "'+username+'" is too short!';
						document.getElementById('usrname2').style = 'background-color: #faa; border-bottom: #f00 thin solid; width: 400px; border-left: #f00 thin solid; width: 400px; border-right: #f00 thin solid; width: 400px;';
					}
				}
			} 
		}
	}
	http.open('get', 'data.php?act=regUsername&name='+username, true); 
	http.send(null);
}

function regPassword(password){
	http.onreadystatechange = function(){
		if(http.readyState == 4 && http.status == 200){  
			var response = http.responseText;
			if(response) { 
				if(response == 1){

				}else if(response == 2){
					document.getElementById('pwdsucc').value = 1;
					document.getElementById('password').style = 'background-color: #afa; border-top: #0f0 thin solid; width: 400px; border-left: #0f0 thin solid; width: 400px; border-right: #0f0 thin solid; width: 400px;';
					document.getElementById('password2').innerHTML = 'Password is OK!';
					document.getElementById('password2').style = 'background-color: #afa; border-bottom: #0f0 thin solid; width: 400px; border-left: #0f0 thin solid; width: 400px; border-right: #0f0 thin solid; width: 400px;';
				}else{
					document.getElementById('pwdsucc').value = 2;
					document.getElementById('password').style = 'background-color: #faa; border-top: #f00 thin solid; width: 400px; border-left: #f00 thin solid; width: 400px; border-right: #f00 thin solid; width: 400px;';
					document.getElementById('password2').innerHTML = 'Password too short!';
					document.getElementById('password2').style = 'background-color: #faa; border-bottom: #f00 thin solid; width: 400px; border-left: #f00 thin solid; width: 400px; border-right: #f00 thin solid; width: 400px;';
				}
			} 
		}
	}
	http.open('get', 'data.php?act=regPassword&pwd='+password, true); 
	http.send(null);
}

function security(entered, created){
http.onreadystatechange = function(){
		if(http.readyState == 4 && http.status == 200){  
			var response = http.responseText;
			if(response) { 
				if(response == 1){

				}else if(response == 2){
					document.getElementById('codesucc').value = 1;
					document.getElementById('sec1').style = 'background-color: #afa; border-top: #0f0 thin solid; width: 400px; border-left: #0f0 thin solid; width: 400px; border-right: #0f0 thin solid; width: 400px;';
					document.getElementById('sec2').innerHTML = 'Code is OK!';
					document.getElementById('sec2').style = 'border-right: #0f0 thin solid; width: 400px;  border-left: #0f0 thin solid; width: 400px; border-bottom: #0f0 thin solid; width: 400px; background-color: #afa;';
				}else{
					document.getElementById('codesucc').value = 2;
					document.getElementById('sec1').style = 'background-color: #faa; border-top: #f00 thin solid; width: 400px; border-left: #f00 thin solid; width: 400px; border-right: #f00 thin solid; width: 400px;';
					document.getElementById('sec2').innerHTML = 'Code is wrong!';
					document.getElementById('sec2').style = 'background-color: #faa; border-bottom: #f00 thin solid; width: 400px; border-left: #f00 thin solid; width: 400px; border-right: #f00 thin solid; width: 400px;';
				}
			} 
		}
	}
	http.open('get', 'data.php?act=regCode&org='+created+'&cre='+entered, true); 
	http.send(null);
}

function reg(usr, usrSuccessful, pwd, pwdSuccessful, codeSuccessful){
if(usrSuccessful == 1 && pwdSuccessful == 1 && codeSuccessful == 1){
	http.onreadystatechange = function(){
		if(http.readyState == 4 && http.status == 200){  
			var response = http.responseText;
			if(response) { 
				if(response == 1){
					alert('Error: Username and password are the same!');
				}else if(response == 2){
					alert("Error: Username or password is blank!");
				}else if(response == 3){
					alert("Error: Password too short!");
				}else if(response == 4){
					alert("Error: Username has been taken!");
				}else if(response == 5){
					alert("Error: Cannot insert data into database!");
				}else if(response == 6){
					document.getElementById('body').innerHTML = '<h2>Login</h2><br /><h3>Registered with the username: '+usr+'</h3><br/><form action="?act=login" method="post">Username: <input name="usr" id="usr" type="text" size="20" maxlength="100" /><br />password: <input name="pwd" id="pwd" type="password" size="20" maxlength="100" /><br /><input name="login" type="submit" onclick="this.value = \'Logging in...\'; document.title=\'Logging in...\';" value="Login" /><br /></form>';
				}else{

				}
			}
		}
	}
	http.open('get', 'data.php?act=reg&usr='+usr+'&pwd='+pwd, true); 
	http.send(null);
}else{
	alert('Error');
}
}

 

Errors:

 

When entering something in the username field, IE gives:

 

Line: 62

char: 7

error: Member not found

Code: 0

 

When entering something into the password field, IE gives:

 

Line: 97

char: 7

error: Member not found

Code: 0

 

And for the Security code field, IE gives:

 

Line: 38

Char: 1

Error: Object doesnt support this action

Code: 0

 

so can anyone give me more light on this?

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.