Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Feb 2012
    Posts
    41
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Merging a small php code in register.php file

    Hello friends,

    Here are two .php codes.

    register.php
    Code:
    <?php 
    include('header.php');
    if($is_online){redirect('index.php');}
    
    if(
    .
    .
    .
    .
    .
    .
    include('footer.php');?>
    ip.php
    Code:
    <?php
    $url = json_decode(file_get_contents("http://api.ipinfodb.com/v3/ip-city/?key=<abcd>&ip=".$_SERVER['REMOTE_ADDR']."&format=json"));
    
    echo $url->countryName;
    ?>
    ip.php is taken from [http://blog.theonlytutorials.com/use...e-php-script/] it gives the IP address of the user.

    When the user goes to mydomain.com/register.php file, I want to check an user's IP address and if his IP belong to a specific country of my choice only then give him a chance to register else show a popup box with a link of some other page to register. "This place is not for you, you may register <<here>>"

    How can I edit the register.php page to include line from ip.php file that suits my needs?

    Thank you.

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,315
    Thanks
    23
    Thanked 612 Times in 611 Posts
    How can I edit the register.php page to include line from ip.php file that suits my needs?
    You don't.
    Use the ip.php as your landing page, index.php. Get the users country and relocate them for there using a if/else statement.
    Evolution - The non-random survival of random variants.

    "If you leave hydrogen alone, for long enough, it begins to think about itself."

  • #3
    New Coder
    Join Date
    Feb 2012
    Posts
    41
    Thanks
    9
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by sunfighter View Post
    You don't.
    Use the ip.php as your landing page, index.php. Get the users country and relocate them for there using a if/else statement.
    Thank you for your reply

    The issue is I am not a coder and I dont know php syntax. Moreover, I allready have a index.php page which is the default landing page. Now if the user goes to register, a code should run and check the IP. For example, if the IP belongs to the country "Australia", the code should allow the user to register, else throw a pop up saying "This place is not for you, you may register <<here>>".

    I need help in writing the code/syntax.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •