Dynadot .com transfer sale, only $10.12 with coupon code DYNA12, available while supplies last, ends October 31, 2026.

Post request bug

Namecheap AuctionsNamecheap Auctions
SpaceshipSpaceship
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.
GoDaddyGoDaddy
anyone able to help me?
 
0
•••
DomainEasy: white label portfolios are live. Enable yours.

We're social

Escrow.com
Spaceship
Escrowly
CryptoExchange.com
Domain Recover

NamePros updates

New in Parking: updated way to act on many domains or inquiries at once
Your domain list and inquiry list now have a bar above and below the list. Check the items you want, then choose an action in the bar...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back