Unstoppable Domains โ€” AI Assistant

Post request bug

SpaceshipSpaceship
Watch

gold killer

Account Closed
Impact
0
Not submitting form

I'm abit new to ajax, one of my friends helped me with an ajax script for an old site, he is now on holiday so i cant ask him. I wanted to give editing it a shot to try and login, so i had to add another value and edit the parameters, now it doesnt seem to work.

The javascript is:
Code:
//Request
var http_request = getHTTPObject();
var url = "post_login.php?";

function getHTTPObject() {
  var xmlhttp = false;
if (window.XMLHttpRequest){
xmlhttp = new XMLHttpRequest();
}
else if (window.ActiveXObject){
try{
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} 
catch (e){
try{
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e){}
}
}

  return xmlhttp;
}


// Ajax 
   function makePOSTRequest(id) {

	  it = document.getElementById("username").value +
	  document.getElementById("password").value;
	  parameters = 'username=' + encodeURIComponent(it) + '&password=' + encodeURIComponent(it) + '&id=' + encodeURIComponent(id);
	  http_request.open('POST', url, true);
	  http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	  http_request.onreadystatechange = alertContents;
	  http_request.send(parameters);
   }

   function alertContents() {
	  if (http_request.readyState == 1) {
			document.getElementById('result').innerHTML = '<img src="loading.gif" />';			 
	  }
	  if (http_request.readyState == 4) {
			results = http_request.responseText;
			document.getElementById('result').innerHTML = results;			   
	  }
   };

The html im using is:
PHP:
echo("
 Username:<br /> <input type=\"text\" name=\"username\" class=\"nav\" /><br />
Password:<br />
<input type=\"password\" name=\"password\" class=\"nav\" /><br />
<input type=\"button\" class=\"nav\" onclick=\"javascript: makePOSTRequest('".$profile[id]."')\" value=\"Login!\"><br />
<strong><a href=\"/index.php?y=register\">Not Registered?</a></strong>");

the .php page that the request should go to:
PHP:
ob_start();
session_start();
include ("config.php");
$id = intval($_POST[id]);

$username = $_POST['username'];
$password = md5($_POST['password']);

$info = mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error());
$data = mysql_fetch_array($info);
if($data[password] != $password)
{
echo "Incorrect username or password!";
}
else
{
setcookie("essex_id", $logged[id],time()+(62*60*23*10), "/", "");
setcookie("essex_pass", $logged[password],time()+(62*60*23*10), "/", "");
$_SESSION[essex_id] = $logged[id];
$_SESSION[essex_pass] = $logged[password];
}
when you press login nothing happens, no error but no login or failed login attempt so its not sending the data to the php page

Please can someone help me,

Thanks

ps, the script was working before with 1 request and no <form> tags!
 
Last edited:
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
Unstoppable Domains โ€” AI StorefrontUnstoppable Domains โ€” AI Storefront
anyone able to help me?
 
0
•••
Dynadot โ€” .com TransferDynadot โ€” .com Transfer
Appraise.net
Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
NameMaxi - Your Domain Has Buyers
DomDB
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back