当用户通过php点击社交图标时,如何重定向社交URL?

时间:2016-10-07 06:47:06

标签: php facebook-social-plugins

html代码:

<a href="http://www.facebook.com/sharer.php?u=https://simplesharebuttons.com" target="_blank"><i class="fa fa-facebook"></i></a>

我的问题是,我想在用户点击Facebook按钮时将用户重定向到其Facebook网址,如$ facebookid = facebook URL

2 个答案:

答案 0 :(得分:0)

假设你有facebook url:

$facebookid = "https://web.facebook.com/abcxyz...";

将它放在html代码中:

<a href="<?php echo $facebookid?>" target="_blank"><i class="fa fa-facebook"></i></a>

希望这会有所帮助..

答案 1 :(得分:0)

我遇到了同样的问题,但是它将Facebook呈现为相对路径而不是链接

   while($row = mysqli_fetch_array($result))
            {
                echo "<div class='col-md-6 col-lg-4 text-center mb-5' data-aos='fade-up'>
                <img src='../images/person_4.jpg' alt='Image' class='img-fluid w-50 rounded-circle mb-4'>
                <h2 class='text-black font-weight-light mb-4'>" . $row['name'] . " " . $row['surname'] . "</h2>
                <p class='mb-4'>Years of experience:  " . $row['experience'] . "</p>";
                
                if ($row['man'] == 1)
                    echo "<i class='fa fa-male' aria-hidden='true'> </i>";
                if ($row['woman'] == 1)
                    echo "<i class='fa fa-female' aria-hidden='true'> </i>";
                
                echo "<a href=' " . $row['facebook'] . "' target='_blank'> <i class='fa fa-facebook' aria-hidden='true'> </i> </a>
                <a href=' " . $row['instagram'] . "' target='_blank'> <i class='fa fa-instagram' aria-hidden='true'> </i> </a>
                <a href=" . $row['email'] . " target='_blank'> <i class='fa fa-envelope-o'  aria-hidden='true'></i> </a>
                </div>";
            }
            echo "</div>";