Jump to content
MakeWebGames

Output my PHP page FROM another WEBSITE with JavaScript


Recommended Posts

Posted

I don't want to use iFrame. Here is what I came up with, but its not working.. It displays nothing.

I place this code on external SITE to try to call my PHP file.

<script type="text/javascript" src="http://somedomain.com/pet.php?petID=5"></script>

 

my pet.php page just calls the class in pet.class.php on "somedomain.com" so I'll just post the pet.class.php file

<

?php
class pet
{

//construct
function __construct()
{					
	$this->petDisplay();
}

//show pet
function petView($petData)
{
	//vars to replace in looper file
	$replacers = array("{NAME}", "{IMG}", "{LVL}", "{LID}");

	//open template file
	$first_sec = file_get_contents("template/pet.htm");
	$template = str_replace($replacers, $petData, $first_sec);
	Header("content-type: application/x-javascript");
	echo $template;
}

//get all user pets
function petDisplay()
{
	require_once('mysql.class.php');

	//vars
	$mysql = new mysql(); 
	$petID = $_GET['petID'];
	$petUserID = $_GET['petUserID'];

	//get pet
	$mysql->query("SELECT pets.petID, pets.petName, pets.petFileType, userpets.upPetID, userpets.upHits FROM userpets, pets WHERE userpets.upID='$petID' AND pets.petID=userpets.upPetID");

	$data = mysql_fetch_assoc($mysql->result);
	$hits = $data['upHits'] + 1;
	$petsID = $data['upPetID'];


	//get potential new pet
	$mysql->query("SELECT petID, petReq, petName, petFileType FROM pets WHERE petParentID='$petsID'");
	$dataNew = mysql_fetch_assoc($mysql->result);

	//LEVEL UP!!
	if($hits >= $dataNew['petReq'] && $dataNew['petReq'] != 0)
	{

		$newPetID = $dataNew['petID'];

		//update user pet sql data
		$mysql->unreturnquery("UPDATE userpets SET upPetID='$newPetID', upHits='1' WHERE upID='$petID'");

		//send email about LEVEL UP!!
		$msg = "Your pet has advanced to " . $dataNew['petName'] . ". View your new pet at somedomain.com/mypets.php";
		$header = "From: SECRET SITE <[email protected]>\n\r";
		mail($email, "Congradulations on Pet Advance", $msg, $header);

		//set data
		$pet = array($dataNew['petName'], "pets/" . $dataNew['petName'] . '.' . $dataNew['petFileType'], 1);
	}
	else
	{
		$mysql->unreturnquery("UPDATE userpets SET upHits='$hits' WHERE upID='$petID'");
		//set data
		$pet = array($data['petName'], "pets/" . $data['petName'] . '.' . $data['petFileType'], $hits);
	}

	$this->petView($pet);
}


}
?>

 

Any ideas. If I call pet.php by itself. It will output my template which is just an image. ;]

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.   Paste as plain text instead

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