I have two websites (support.mahtt.host and phonezone.ir), and I want my test.php file in phonezone.ir reads prices from support.mahtt.host. As per WHMCS documentation, everything works fine but I want it works in another way. Please check this file: http://phonezone.ir/saeed/test.php It reads the name from http://phonezone.ir/saeed/name.php and the price from http://phonezone.ir/saeed/price.php, but as you see in its HTML codes, Javascript tag is shown that from which site the price and name are read.
I've started learning PHP recently and I don't know what to search for it exactly over the web. I have tried to work with file_get_contents() and curl() function, but I think I have tried the wrong ones.
name.php contents (php tags are omitted):
$name = "<script language='javascript' src='https://support.mahtt.host/feeds/productsinfo.php?pid=1&get=name'></script>";
price.php contents (php tags are omitted):
$price = "<script language='javascript' src='https://support.mahtt.host/feeds/productsinfo.php?pid=9&get=price&billingcycle=monthly'></script>";
test.php contents (php tags are omitted):
include ("./name.php");
include ("./price.php");
echo "The price of $name is $price.";
The current html output is:
The price of <script language='javascript' src='https://support.mahtt.host/feeds/productsinfo.php?pid=1&get=name'></script> is <script language='javascript' src='https://support.mahtt.host/feeds/productsinfo.php?pid=9&get=price&billingcycle=monthly'></script>.
I want HTML output be like as it's shown in the browser, like this:
The price of IRcPanel-A is 81,000 تومان.
And when I or any other visitor sees, we only see the above output in both browser and html output.
Could you please help me what should I do to get my expected result?
I have solved this issue by using php codes instead of JS tags.
I have created another .php file called db.php with the below contents:
<?php
$servername = "MyServerIP";
$username = "user_name";
$dbname = "db_name";
$password = "some_password";
$saeedIsCool = new mysqli($servername, $username, $password, $dbname);
if ($saeedIsCool->connect_error) {
die("Connection failed: " . $saeedIsCool->connect_error);
}
$sql = "SELECT monthly FROM tblpricing WHERE id = 1";
$result = $saeedIsCool->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
$id1Product = "". $row["monthly"]." Toman";
}
} else {
echo "0 results";
}
$floorid1Product = floor($id1Product). " Toman";
$saeedIsCool->close();
?>
And have modified my test.php contents as below:
<?php
include ("./name.php");
include ("./db.php");
echo "The price of {$name} is {$floorid1Product} Toman per month";
?>
And now the result is as expected:
The price of IRcPanel-A is 11200 Toman per month