The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS HELP: PHP redirct within a certain div rather than an entire site page

  • This topic is empty.
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
  • #40776

    I manage my schools robotics team website but i cant embed youtube videos onto the website without the school blocking it. they have agreed to not block it if i can specify for the videos to not be shown if the IP if the ip that the school uses for student computers.
    Can i make a specific content div within a page display a youtube video if an ip is anything except for the 1 specific ip that all of the school computers have? also how would i have it display something besides the video like an error image instead of the video.

    i have fundamental PHP knowledge and i assume this is what is involved.
    Alternativly i can have the page redirect to another page on my website like rather than /content. which way would be an easier/better way to do this and could someone help me write the code for this?



    Hey @tylerrichardson96

    Sounds quite strange the way you would have to go through all that just to get a YouTube video to work on your website.

    What you could do however is open YouTube, search for the video and click it, then grab the URL of that video and copy it.

    Once you have that you could head on over to and enter the URL in the address bar on there. Save it in a different format (for example – .FLV) and download it to your computer.

    Then you could just use a plugin such as [FlowPlayer]( “”) and embed it that way?


    @traq, im not sure how to write the code at all, ive done a bit of research and i found this redirect based on ip:

    $allowed = array(“”);
    $ip = $_SERVER;
    if(!in_array($ip, $allowed))
    header(“Location:; /* Redirect browser */
    /* Make sure that code below does not get executed when we redirect. */


    how can i manipulate this to make it apply to a single element (my div with the youtube video) rather than the entire page of the website?


    Thanks so much!!! 1 last question, how can i have it display something else instead of the video, i assume i would put it after the 2nd print, but what is the php syntax for ‘printing’ a picture?


    These is no such special syntax.

    PHP is not an “alternative” to HTML; PHP *writes* HTML.

    print ‘my picture‘;

    (Yes, it would be inside the `else` block.)


    Thanks so much :) i put the code into my website and this is what is looks like i dont have my blocked ip yet so i have both ip events as the same thing. can you tell me why the code is showing up in the website?


    My guess is that you haven’t closed a tag or something.

    FIRST Videos

    $userIP = $_SERVER;
    $badIP = ‘’;
    if( $userIP == $badIP ){
    print ‘‘;
    print ‘‘;



    > this is what is looks like

    actually, I get a 404.

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.