2013-07-26 151 views
0

你好的人,我只是想問問這是怎麼做到讓下面的代碼在PHP需要簡單的PHP一些幫助

<input type="text" name="SteamID64"> 
當人進入

並按下按鈕後,那麼它應該填寫該值下面

<?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; 
?> 

我很抱歉,如果我做了這個問題錯了,我是新來的

回答

1

使用$_POST拿到ID:

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

我假設你已經得到形式設置正確,是這樣的:

<form action="TheTarget.php" method="post"> 
    <input type="text" name="SteamID64" /> 
    <input type='submit' value='submit' /> 
</form> 
0
if (isset($_POST['SteamID64'])) { 
$id = $_POST['SteamID64']; 
$xml = simplexml_load_file("http://steamcommunity.com/profiles/{$id}?xml=1"); 
}