如何插入变量? 从一种形式到的file_get_contents链路(how do i inse

2019-11-01 17:40发布

如何插入从表单的可变成的file_get_contents(“链接+ FORMDATA”)

可变正通过表单提交,并包含句号,数字,字母

例如:danny.29将在下面的链接取代的位置:

的file_get_contents( “ http://userapi.website.com/HERE ”);

正如你看到的我是很新的这一点,任何帮助将是非常赞赏:)

的index.html

<html>
<body>

<form action="add.php" method="post">
ID: <input type="text" name="add">
<input type="submit">
</form>

</body>
</html>

add.php

<html>
<body>

<?php $x=$_POST['add'];?>

<?php
echo file_get_contents("http://userapi.website.com/"echo $x;");
?>

<?php echo $_POST["file_get_contents"]; ?>

</body>
</html>

Answer 1:

<?php echo file_get_contents("http://userapi.website.com/" . $x); ?>

点是级联



Answer 2:

<?php echo $_POST["file_get_contents"]; ?>

没有意义。 接线柱阵列将只包含add的第一负载的关键。

echo file_get_contents("http://userapi.website.com/". $x);

将得到正确的,但把它记到你只需要做一个变量的地址页面的内容:

$var = file_get_contents("http://userapi.website.com/". $x);

另外这个剧本没有完全安全的。 你应该总是验证用户输入(在这种情况下,您的POST变量)。 我建议你使用正则表达式或变量可接受值的列表。



文章来源: how do i insert a variable? from a form into a file_get_contents link