如何在链接中插入带变量的变量?

时间:2017-04-13 15:21:17

标签: javascript php html function

HTML代码:

<html>
<body>
    <?php
        if (isset($_POST['submit'])){
            $idfb = $_POST['idfb'];
            $url = "http://graph.facebook.com/$idfb/picture?type=$size";
        }
    ?>
    <input name="idfb" id="idfb" required placeholder="Enter the ID in this field" type="text">
    <button type="submit" class="button" href="loading.php">Hack this Facebook Account</button>
    <center><img class="thumbnail" src="http://graph.facebook.com/<?php echo $idfb ?>/picture?type=large"></center>
</body>
</html>

所以我想将输入中的Facebook ID插入链接并获取此帐户ID的个人资料图片。 这是正确的方式吗?

1 个答案:

答案 0 :(得分:1)

试试这个:

<html>
    <head>
    </head>
    <body>
        <?php
if (isset($_POST['submit']))
{
    $idfb = $_POST['idfb'];
    $url = "http://graph.facebook.com/".$idfb."/picture?type=large";
}
        ?>
        <form action="" method="POST">
            <input name="idfb" id="idfb" required placeholder="Enter the ID in this field" type="text">
            <input type="submit" name="submit" class="button" value="Hack this Facebook Account" />
            <?php if(isset($url)) { ?>
            <center>
                <img class="thumbnail" src="
<?php echo $url; ?>">
            </center>
            <?php } ?>
        </form>
    </body>
</html>

您在HTML代码中几乎没有错误来获得正确的值。