Search Results

Search found 4 results on 1 pages for 'neethusha'.

Page 1/1 | 1 

  • GET and XMLHttpRequest

    - by Neethusha
    i have an XMLHttpRequest.The request passes a parameter to my php server code in /var/www. But i cannot seem to be able to extract the parameter back at the server side. below i have pasted both the codes: javascript: function getUsers(u) { alert(u);//here u is 'http://start.ubuntu.com/9.10' xmlhttp=new XMLHttpRequest(); var url="http://localhost/servercode.php"+"?q="+u; xmlhttp.onreadystatechange= useHttpResponse; xmlhttp.open("GET",url,true); xmlhttp.send(null); } function useHttpResponse() { if (xmlhttp.readyState==4 ) { var response = eval('('+xmlhttp.responseText+')'); for(i=0;i<response.Users.length;i++) alert(response.Users[i].UserId); } } servercode.php: <?php $q=$_GET["q"]; //$q="http://start.ubuntu.com/9.10"; $con=mysql_connect("localhost","root","blaze"); if(!$con) {die('could not connect to database'.mysql.error()); } mysql_select_db("BLAZE",$con) or die("No such Db"); $result=mysql_query("SELECT * FROM USERURL WHERE URL='$q'"); if($result == null) echo 'nobody online'; else { header('Content-type: text/html'); echo "{\"Users\":["; while($row=mysql_fetch_array($result)) { echo '{"UserId":"'.$row[UsrID].'"},'; } echo "]}"; } mysql_close($con); ?> this is not giving the required result...although the commented statement , where the variable is assigned explicitly the value of the argument works...it alerts me the required output...but somehow the GET method's parameter is not reaching my php or thats how i think it is....pls help....

    Read the article

  • Parsing JSON with eval

    - by Neethusha
    I have this code: function useHttpResponse() { if (xmlhttp.readyState==4 ) { var response = eval('('+xmlhttp.responseText+')'); alert(response); for(i=0;i<response.Users.length;i++) alert(response.Users[i].UserId); } } When i alert, the first alert is "[object Object]" Why is that so? I need to remove that...how?

    Read the article

  • POSTmethod and PHP- login verification

    - by Neethusha
    I wrote a code for login verification..I got output with GET. But i need output with POST since it is more secure.pls let me know if there is any error in my code. javascript code: var xml; function verifyusernamepasswd(pass) { //pass is password that will be passed as parameter xml=new XMLHttpRequest(); var url="http://localhost/loginvalidate.php"; var para="q="+username+"&p="+pass;//username is global xml.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xml.setRequestHeader("Content-length", para.length); xml.setRequestHeader("Connection", "close"); xml.open("POST",url,true); xml.onreadystatechange=statechanged1; xml.send(para); } function statechanged1() { if(xml.readyState==4) alert(xml.responseText); } php code: <?php $username=$_POST["q"]; $password=$_POST["p"]; $con=mysql_connect("localhost","root","blaze"); if(!$con) { die('Could not connect: '.mysql.error()); } mysql_select_db("BLAZE",$con) or die("No such Db"); $result=mysql_query("SELECT Passwword FROM USERTABLE WHERE Userhandle='$username'"); if($result==null) echo "false"; else if($result!=null) { $row=mysql_fetch_array($result); if((strcmp($row['Passwword'],$password)==0)) echo "true"; else echo "false"; } ?> the verification does not return anything, cos my alert is not displayed at all...pls tell me whats wrong....

    Read the article

1