Question

Hello people i just wanted to ask this that how to do make the below code in PHP

<input type="text" name="SteamID64"> 

when the person enters and clicks the button then it should fill that value in the below

    <?php
$xml=simplexml_load_file("http://steamcommunity.com/profiles/<STEAMID64 HERE>?xml=1");

echo $xml->steamID . "<br>";
echo $xml->onlineState . "<br>";
echo $xml->privacyState . "<br>";
echo $xml->avatarFull . "<br>";
echo $xml->body;
?>

I am sorry if i have done this question wrong i am new here

Was it helpful?

Solution

Use $_POST to get the id:

$format = "http://steamcommunity.com/profiles/%s?xml=1";
$url = sprintf($format, $_POST["SteamID64"]);
$xml=simplexml_load_file($url);

I'm assuming you've got the form set up correctly, something like:

<form action="TheTarget.php" method="post">
    <input type="text" name="SteamID64" /> 
    <input type='submit' value='submit' />
</form>

OTHER TIPS

if (isset($_POST['SteamID64'])) {
 $id  = $_POST['SteamID64'];
 $xml = simplexml_load_file("http://steamcommunity.com/profiles/{$id}?xml=1");
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top