PHPTalk.com: Problem on Simple AJAX Program(Please give the reply) - PHPTalk.com

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Problem on Simple AJAX Program(Please give the reply)

#1 User is offline   ran_php Icon

  • Member
  • PipPip
  • Group: Members
  • Posts: 16
  • Joined: 02-March 06

Posted 03 March 2006 - 05:50 AM

hi,


good morning to everyone

i am beginner in the AJAX programming.

i execute the one ajax program ..but it didn't run properly...the code as given below.




  // index.html

<html>
<head><title>Admin Login Page</title>
<script language="javascript" type="text/javascript" src="checkLogin.js">
</script>
</head>
<body>
<br><br><br><br><br><br><br><br><br><br>
<form name="form1" action="adminCredinitial.php">
  <table width="303" border="1" align="center" bgcolor="#99CCFF">

    <tr>
      <td width="160"><div align="center"><strong>Enter AdminName </strong></div></td>
      <td width="165"><input type="text" name="name"></td>
    </tr>

    <tr>
      <td><div align="center"><strong>Enter Password </strong></div></td>
      <td><input type="password" name="password"></td>
    </tr>

    <tr>
      <td colspan="2"><div align="center">
        <input type="submit" name="submit" value="Submit"  onclick="check_Login();">
      </div></td>
    </tr>

  </table>
   <div id="resultText">
   </div>
</form>
</body>
</html>


//----------------------------------------------------------------------------------------------------------------------------


// Javascript Document

//checkLogin.js

function createRequestObject(){

var request_o;
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer"){
request_o = new ActiveXObject("Microsoft.XMLHTTP");
}else{
request_o = new XMLHttpRequest();
}
return request_o;

} //end of function createRequestObject()

var http = createRequestObject();

function check_Login(){

  http.open('get','adminCredintial.php?adminName='+document.form1.name.value+'&adminPassword='+document.form1.password.value);
  http.onreadystatechange = handleMessage;
  http.send(null);

}  //end of function chekc_Login()

function handleMessage(){
 
  if(http.readyState==4){
    var response=http.responseText;
    document.getElementById('resultText').innerHTML = response;
    return false;
  }

} //end of function handleMessage()


//--------------------------------------------------------------------------------------------------


<!-- adminCredintial.php -->


<?php
  $adminName="";$adminPassword="";
  if(isset($_GET))  {
     $adminName=$_GET['adminName'];
     $adminPasssword=$_GET['adminPassword'];   
  }
   
  if($adminName=='admin' && $adminPassword=='admin') {
      echo "You are a valid member";exit;
  }
  else {
      echo "You are not a valid member";
  }

?>

//------------------------------------------------------------------------


plz give the reply about the above code...


regards
--------
ran_php
0

#2 User is offline   Kuulest Icon

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 326
  • Joined: 20-April 02

Posted 04 March 2006 - 05:14 PM

Hi,
Generally outputting great amount of code into post ensures that nobody cares to go through it, and your question stays unresolved.
Could you please specify what goes wrong, what error messages you get, plus giving us some info regarding how acctually script is supposed to behave (if runs correctly) would ge great.

Thanks,
Torio
0

#3 User is offline   starshant Icon

  • Newbie
  • Pip
  • Group: Members
  • Posts: 0
  • Joined: 23-December 09

Posted 23 December 2009 - 11:13 AM

hello,

firstly <form> tah has no method specified.
you should use POST method in it and access parameters by $_POST['param'].

others are working fine.
0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users