Jump to content

[SOLVED] Using GET isnt working.


Eggzorcist

Recommended Posts

Alright, heres my JS code. All works but one thing. It seems like my PHP code isn't receiving any GET information but I'm having trouble seeing how it isnt.

 

 

// JavaScript Document

var xmlhttp;

function showUser(str)
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  }
var url="trackeractions.php";
url=url+"?id="+str;
//url=url+"&sid="+Math.random();
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}

function stateChanged()
{
if (xmlhttp.readyState==4)
{
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
}
}

function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}

 

 

 

I'm not that good in AJAX. This is for my media design class.

 

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/161156-solved-using-get-isnt-working/
Share on other sites

here's the PHP code.

 

<?php
$dbhost = "localhost";
$dbuser = "root";
$dbpass = "";
$dbname = "tgj4u";


mysql_connect($dbhost, $dbuser, $dbpass);
mysql_select_db($dbname) or die(mysql_error());
$id =  $_GET['id'];
$id = mysql_real_escape_string($id);
$query = "SELECT * FROM maildata WHERE id = '$id'";
$qry_result = mysql_query($query);



if (mysql_num_rows($qry_result)){


while($info = mysql_fetch_assoc($qry_result)){

echo "Sent by: " . $info['sender'] . "<br>";	
echo "Recipient: " . $info['recipient'] . "<br>";	
echo "Departed: " . $info['depart'] . "<br>";
echo "Satus: " . $info['depart'] . "<br>";
echo "Current Location: " . $info['currentlocation'] . "<br>";
echo "Arrival Location: " . $info['finallocation'] . "<br>";
echo "Expected on: " . $info['expected'] . "<br>";

}
}

else
{
   echo "<p>No data was found with that ID.</p>\n";
}





?>

 

I've tried with both mizila firefox and internet explorer.

ah here is there error:

 

<form>
Package ID:<input name="id" type="text" id='id' value="f" size="10" maxlength="10" /> 
<br />
<input type='button' onclick='showUser(this.value)' value="Track"/>
</form><br />

 

What is being tracker is the wrong value. I want it to pickup the value to value="f" but what it is picking up now is value="track" which is the button value, what is the command to change it to the text box?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.