I can i do this with PHP

Discussion in 'PHP' started by ChristopherLeeMaher.Com, Jun 25, 2010.

  1. #1
    Hey, I have a php file located at http://example.com/connect.php how can i make it shows different content when some one views http://example.com/connect.php?ip=205-251-138-58 they see
    
    <html>
    
    <head>
    <title></title>
    <meta http-equiv="REFRESH" content="5;url=http://205-251-138-58.clmproxy.com/connect.php
    
    <body>
    <center>
    <h2>You Are Now Being Connected To <a href="http://205-251-138-58.clmproxy.com/connect.php">http://205-251-138-58.clmproxy.com/connect.php</a></h2>
    <img src="http://img51.imageshack.us/img51/7712/loadinganimation.gif" />
    If your not redirected please click <a href="http://205-251-138-58.clmproxy.com/connect.php">Here</a></a>
    
    </center>
    </body>
    
    </html>
    
    HTML:
    and if they visit http://example.com/connect.php it redirects them it http://example.com/
     
    ChristopherLeeMaher.Com, Jun 25, 2010 IP
  2. raredaredevil

    raredaredevil Greenhorn

    Messages:
    59
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #2
    I will assume the data is set as a GET request not as POST , let me know if it works as ive not tested :p if theres a error it should be something simple
    
    
    <?php
    if ($_GET['ip'] <> "205-251-138-58" && !isset($_GET['ip'])) 
    {
    //Error occured so goto index.php
    print "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.0 Transitional//EN'>
    <html>
    <head>
    <title>ERROR</title>
    <meta http-equiv='REFRESH' content='0;url=http://www.yoursite.com'></HEAD>
    <BODY>
    Error occured , redirecting to home.....
    </BODY>
    </HTML>";
    }
    else
    {
    print "<html>
    
    <head>
    <title></title>
    <meta http-equiv='REFRESH' content='5;url=http://205-251-138-58.clmproxy.com/connect.php
    
    <body>
    <center>
    <h2>You Are Now Being Connected To <a href='http://205-251-138-58.clmproxy.com/connect.php'>http://205-251-138-58.clmproxy.com/connect.php</a></h2>
    <img src='http://img51.imageshack.us/img51/7712/loadinganimation.gif' />
    If your not redirected please click <a href='http://205-251-138-58.clmproxy.com/connect.php'>Here</a></a>
    
    </center>
    </body>
    
    </html>";
    }
    ?>
    
    Code (markup):
     
    raredaredevil, Jun 25, 2010 IP
  3. ChristopherLeeMaher.Com

    ChristopherLeeMaher.Com Guest

    Messages:
    185
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I get a
    Parse error: syntax error, unexpected '{' in /home/myihacki/clmproxy.com/public_html/connect.php on line 1
    Code (markup):
     
    ChristopherLeeMaher.Com, Jun 25, 2010 IP
  4. raredaredevil

    raredaredevil Greenhorn

    Messages:
    59
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #4
    Must be on your side, I just uploaded it to my own domain and tested it and it worked :p, copy paste that enite code into a brand new .php file unedited , it will work :p

    p.s the error says there was a unexpected "{" on line 1 but line 1 of my code does not have a "{"
     
    raredaredevil, Jun 25, 2010 IP
  5. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #5
    <?php
    if (@$_GET['ip'] == "205-251-138-58") {
    ?>
    <html>
    
    <head>
    <title></title>
    <meta http-equiv="REFRESH" content="5;url=http://205-251-138-58.clmproxy.com/connect.php
    
    <body>
    <center>
    <h2>You Are Now Being Connected To <a href="http://205-251-138-58.clmproxy.com/connect.php">http://205-251-138-58.clmproxy.com/connect.php</a></h2>
    <img src="http://img51.imageshack.us/img51/7712/loadinganimation.gif" />
    If your not redirected please click <a href="http://205-251-138-58.clmproxy.com/connect.php">Here</a></a>
    
    </center>
    </body>
    
    </html>
    <?php
    } else {
    
    header("Location: http://example.com/");
    
    }
    
    ?>
    PHP:
     
    danx10, Jun 27, 2010 IP