ajax...

i have 3 pages which is used to change the password of customers…

ex.html ajax.js then ex.php

everything works smoothly… but database table won’t be updated…

it just make the fields into ‘0’ value…

can anyone help me???

Sure we may be able to help. But need to see some code and such.

ex.html

<html>
<body>

<script src="ajax.js"></script>
<form name='myForm'>
OLD: <input type='text' id='old' /> <br />
NEW1: <input type='text' id='new1' /> <br />
NEW2: <input type='text' id='new2' /> <br />

<input type='button' onclick='ajaxFunction()' value='Query MySQL' />
</form>
<div id='ajaxDiv'>Your result will display here</div>
</body>
</html>[/code]

ajax.js

[code]<!-- 
//Browser Support Code
function ajaxFunction(){
	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			<!--document.myForm.ID.value = ajaxRequest.responseText;-->
			var ajaxDisplay = document.getElementById('ajaxDiv');
			ajaxDisplay.innerHTML = ajaxRequest.responseText
		}
	}
	var old = document.getElementById('old').value;
	var new1 = document.getElementById('new1').value;
	var new2 = document.getElementById('new2').value;
	
	var queryString = "?old=" + old + "&new1=" + new1 + "&new2=" + new2;
	ajaxRequest.open("GET", "ex.php" + queryString, true);
	ajaxRequest.send(null); 
}

//-->

ex.php

[code]<?php require_once('../Connections/conmyprice.php');?>

<?php $old = md5($_GET['old']); $new1 = md5($_GET['new1']); $new2 = $_GET['new2']; echo $new1.">>>>".$old."
"; mysql_select_db($database_conmyprice, $conmyprice); $sql="SELECT * FROM tbl_csec_det WHERE ID ='1'"; $result = mysql_query($sql); $row = mysql_fetch_array($result); $x=$row['txtpasswd']; //echo $x; if($x==$old){ $display_string="UPDATE tbl_csec_det SET txtpasswd='".$new1."' AND txtquestion='".$new2."' WHERE ID ='1'"; $result1 = mysql_query($display_string) or die (mysql_error()); //$display_string='OKKKKKKKKKKK'; } else { $display_string='I Can't...'.">>>>>>>>>>".$row['txtpasswd']; } echo $display_string; ?>[/code]

password field of table change into value 0 when run the script…

OK… Buddy…

I found it… the problem is with sql query…

it should be…

$display_string="UPDATE tbl_csec_det SET txtpasswd='".$new1."', txtquestion='".$new2."' WHERE ID ='1'";

instead of this

$display_string="UPDATE tbl_csec_det SET txtpasswd='".$new1."' AND txtquestion='".$new2."' WHERE ID ='1'";

But…

how do i use only .php and .js pages to achieve this task?

Sponsor our Newsletter | Privacy Policy | Terms of Service