phphtmllocalhostping

Why ping attribute not working correctly in html5


Hi I'm building a tracking system for my project and I'm trying to use the ping attribute, but this attribute not working correctly on localhost.

Here is my code with PHP

echo "<a href='".$r_url."' ping='/redirect?url=".$r_url."'>";

Can anybody tell me what's wrong with this code?


Solution

  • Based on your post and the information you gave in the comments, you are trying to redirect through the link in the ping attribute.

    In the W3C documentation:

    The ping attribute specifies a list of URLs to be notified if the user follows the hyperlink.

    Which means that the user is not directly redirected to this URL, instead this happens:

    1. User clicks on the link
    2. The browser sends a POST request to the URL in the ping attribute
    3. The browser redirects the user to the URL in the href attribute

    If you want to redirect through a URL, simply put your redirection URL in the href attribute:

    echo "<a href='/redirect?url=".$r_url."'>";