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
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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.