Hi
i am using the following method to call the ajax, basically in my main code i have this:
Code:
var ajaxRequest; // The variable that makes Ajax possible!
function tryAjax(){
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;
}
}
}
}
function ajaxfunctionSaveLoginDetails(){
tryAjax();
// Create a function that will receive data sent from the server
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4){
}
}
if(document.SMSForm.rememberPassword[0].checked==true){
var username = document.getElementById('Userkey').value;
var password = document.getElementById('Password').value;
}else if(document.SMSForm.rememberPassword[1].checked==true){
var username = document.getElementById('Userkey').value;
var password = "";
}else if(document.SMSForm.rememberPassword[2].checked==true){
var username = "";
var password = "";
}
var queryString = "?username=" + username + "&password=" + password;
ajaxRequest.open("GET", "ajaxSaveLoginDetails.php" + queryString, true);
ajaxRequest.send(null);
}
and the php file that is being called has the following code:
Code:
<?php
include('db_settings.inc.php');
include('adodb/adodb.inc.php'); # load code common to ADOdb
$conn = &ADONewConnection('mysql'); # create a connection
$conn->PConnect($dbhost,$dbuser,$dbpass,$dbname); # connect to MySQL, agora db
$username = $_GET['username'];
$password = $_GET['password'];
$username = mysql_real_escape_string($username);
$password = mysql_real_escape_string($password);
$query = "DELETE FROM login_details";
$qry_result = $conn->Execute($query);
//build query
$query = "INSERT INTO login_details (Username,Password)";
$query.= "VALUES ('".$username."','".$password."')";
//Execute query
$qry_result = $conn->Execute($query);
echo "Done";
?> I am not sure what the problem with this is tho?
Usually the username from the database appears within the username field, however now the field is now filled with this:
<script type="text/javascript" src="include/javascript/sugar_3.js?s=4.2.0d&c="></script><script type="text/javascript" src="include/javascript/cookie.js?s=4.2.0d&c="></script><link rel="stylesheet" type="text/css" media="all" href="themes/Sugar/calendar-win2k-cold-1.css?s=4.2.0d&c="><script>jscal_today = 1.17024483E+12
i have no idea where this has come from at all, i hope this helps
thanks for your help, much appreciated.
Bookmarks