2013-05-21 54 views
-5

问题答案:https://stackoverflow.com/a/16721000/2217905变量帮助在PHP

<?php 
if(isset($_POST["act"])) { 
$uname = $_POST['username']; //Username 
$uname = str_replace(array('!','"','£','$','%','%','^','&','*','(',')','-','+','=','\\','/','[',']','{','}',';',':','@','#','~','<',',','>','.','?','|',' '), '', $uname); 


// Set some variables and values that you want to be propogated through the URL 

$variable['1'] = $_POST['username']; 

// We now set the base of the dynamic link 

$link = "http://yunodev.com/skinstealer.php"; 

// Add on a question mark to the link, to identify that variables are now being set 
$link .= "?"; 
// Lets add on our first variable to the link 
$link .= $variable['1']; 


} 
?> 
<!-- THIS PAGE IS skinstealer.php --> 
<html> 
<head> 
<title>Minecraft Skin Stealer - Image View</title> 
</head> 
<body> 
<img src="http://s3.amazonaws.com/MinecraftSkins/<?php echo $uname; ?>.png" width="800" height="400" alt="Error"> 
<p><b>Image scaled by 800x400pixels. Will be much smaller, and no blur when downloaded.</b></p> 
<p><a href="http://s3.amazonaws.com/MinecraftSkins/<?php echo $uname; ?>.png">Download Skin</a></p>a 

这是我现在所拥有的代码,基本上我想是这样,当用户转到链接:http://example.com/skinstealer.php?id=Laim它表明皮肤。如果这是有道理的。

从未做过变量之前,所以这是对我来说是新的东西。 GEORGE COMMENT

编辑时,

目前我得到的(如果我赞同)是http://example.com/skinstealer.php?laim 如果我去这个链接,它只是表明我的错误形象。如果需要,我可以上传现场演示。

+0

我想你应该使用$ _GET而不是$ _POST在这个例子中 – Frildoren

+0

请告诉我们你期望发生什么,现在发生了什么,你收到了什么错误信息,以及你尝试过什么要解决这个问题。请考虑只发布代码中最相关的代码片段。 –

+0

或者更好的是,使用'$ _REQUEST' – nullability

回答

0

明白了,最后。 (嗯,我得到了它的一天,但忘了更新为别人谁拥有这个问题这个问题。)

代码以删除:

<?php 
if(isset($_POST["act"])) { 

// Set some variables and values that you want to be propogated through the URL 

$variable['1'] = $_POST['username']; 

// We now set the base of the dynamic link 

$link = "http://yunodev.com/skinstealer.php"; 

// Add on a question mark to the link, to identify that variables are now being set 
$link .= "?"; 
// Lets add on our first variable to the link 
$link .= $variable['1']; 


} <!-- REMOVE THIS 

然后,您可以更改所有“POST”到“GET”,例如这里:http://yunodev.com/download/minecraft/(V5)