#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2017
    Posts
    307
    Rep Power
    1

    Question How To Record Urls Loading on iFrame Into MySql Db ?


    Programmer Experts,



    I'm embarking on an interesting project to gain work experience in php. Just stuck on one thing and wondering if you can help.

    You probably used Team Viewer. This is where I create a Team Viewer session and get a unique number and if I give you it then with that number you can login to my computer and see what is on my screen and you can remotely control my computer.

    Creating something similar. Only difference is, you won't remotely control my computer nor access any parts of my computer but only see what I am viewing in an iframe.

    So, it is like this ...

    I register for a member account. I login to my member account. I add you as "friend". Now, you can view what I am viewing on an iframe.

    My homepage (member account page after I login) will show me 2 iframes. Whatever, I browse on the 1st iframe is remotely viewed by my friends like you. And whatever page you (my friend) is viewing in your 1st iframe gets shown to me on my 2nd iframe.

    So, my 1st iframe records what I'm viewing to show to you, my friend, on your 2nd iframe.

    And my 2nd iframe shows what page you, my friend, are viewing on your 1st iframe inside your member account.

    Simple concept, really. No rocket science.

    So, technically, this is how it works ...

    Whatever url I view in my 1st iframe (whatever url the iframe opens to and whatever links I click inside the iframe) gets recorded onto mysql like so ...

    COLUMN

    User| Latest_Viewing_Url

    UI Man|1.com



    Now, your member acc home page would show the webpage I am viewing in your 2nd iframe.

    Your 2nd iframe pulls that (above mentioned mysql data) data and opens to the webpage mentioned on column (Latest_Viewing_Url) position: 0.

    In this example, your 2nd iframe opens to: 1.com.

    When I move-on to another page (eg. by clicking a link on 1.com) then that gets not INSERTED but UPDATED on "Latest_Viewing_Url" column position: 0.

    And things work vice versa for both of us.

    See, I told you it is an interesting project for a beginner like me. Everything is nearly finished. But a problem:

    How do I get the iframe to record (onto "Latest_Viewing_Url" column; pos: 0, all the links I click inside the iframe (in this example the url I visit after clicking a link on 1.com) ?

    I can code for there to be a "Visit" or "Go To Url" button so when I click it then the url in the "Url" html text box gets recorded onto the db. But that is only recording the urls that I view by clicking the "Go" button. Imagine, I clicked a link inside the iframe. Now, that link will have no connection with the "Go" button. Hence, I'm in a puzzle how to record what links get clicked inside the iframe. If somehow, I can program the script to monitor the url field on the iframe every 5 secs for any changes so when it finds the url has changed then to record it on the db. But guess what ? I have no clue how to do that. Meaning, how to get the script to monitor what url is residing in the iframe url field. I know how to do this in Ubot Studio (.exe bot) but not php. And so, I need your brilliant help!

    Care to show a few samples for all present and future newbies ? Newbies would appreciate your help for future to come!

    A single line of code that notes down every url that loads in the iframe should do the trick!

    What do you think ?



    PHP Code:
    <html>
    <head>
    <title>
    <?php
    $user ?>
     Home Page
    </title>
    </head>
    <body>
    <body background=".png">

    <?php
    session_start
    ();
    require 
    "conn.php";

    /*Check if user is logged-in or not by checking if session is set or not.
    If user is not logged-in then redirect to login page. Else, show user's account homepage.*/

    if(!isset($_SESSION["user"]))
    {
        header("location:login.php");
    }
    else
    {
        $user $_SESSION["user"];
        $sql "SELECT * FROM $user WHERE Username = '".$user."'";
        $result mysqli_query($conn,$sql);
        while($row mysqli_fetch_assoc($result))
        {
            $db_id $row["Id"];
            $db_username $row["Username"];
            $db_forename $row["Forename"];
            $db_surname $row["Surname"];
            $db_email $row["Email"];
            $db_bio $row["Bio"];
            $db_status_to_friends $row["Status_To_Friends"];
            $db_status_to_public $row["Status_To_Public"];
            $db_latest_view $row["Latest_View"];
            $db_upline_1 $row["Upline_1"];
        
        
            
    //Welcome user by name.
            echo "<center>Welcome <b><h2>$db_forename $db_surname!</center>"?></h2></b>|

            <?php
            
    //Display log-out link.
            echo "<p align='right'><a href='logout.php'>$user Log Out</a>";?>|</p><br>
        
            <?php
            
    //Display User's Latest View.
            echo "<br><b>Latest View:</b><br>";
            echo "$db_latest_view";?><br>
            <br>

            <?php
            
    //Display User's Latest Viewed Url in iFrame.?>
            <iframe src='<?php echo $db_latest_view;?>'></iframe>

            <?php
            
    //Display User Bio.
            echo "<br><b>Bio:</b><br>";
            echo "$db_bio";?><br>
            <br>

            <?php
        
    }
    }
    ?>

    </body>
    </html>
    ​​​​​​​Ignore the <center> tags as that is gonna get replaced by css.
    Been working on this project for 2mnths, learning and all. getting tiring now. let's finish it tonight! need to move-on to learning other stuffs! Now don't I ?
    Last edited by UniqueIdeaMan; April 9th, 2017 at 08:11 PM.
  2. #2
  3. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Caro, Michigan
    Posts
    14,810
    Rep Power
    4536
    Unless you're only browsing very simple web pages, there's more to what's displayed than the simple URL of the page. The page is very different when I load facebook.com and when you load it, for example. Just knowing the URL of the iframe you're browsing doesn't guarantee that I'll have the same representation on my end, especially with sessions and cookies.

    This seems like a very odd idea.

    -John
    -- Cigars, whiskey and wild, wild women. --
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2017
    Posts
    307
    Rep Power
    1

    Question


    Originally Posted by Sepodati
    Unless you're only browsing very simple web pages, there's more to what's displayed than the simple URL of the page. The page is very different when I load facebook.com and when you load it, for example. Just knowing the URL of the iframe you're browsing doesn't guarantee that I'll have the same representation on my end, especially with sessions and cookies.

    This seems like a very odd idea.

    -John

    Hi,

    Imagine there is a tbl called "users" and it has a column called "your blog url".
    Now, imagine you want to display that blog's url in an iframe on one of your pages. How would you code it ?
    I did the following but the iframe fails to load the webpage.
    I guess this is due to me failing to get the iframe to pic one url or one entry from the "your blog url" column.

    The best attempt I made was this:

    Code:
    <?php 
        //Display User's blog?>
        <iframe src="<?php $row["blog"];?>"></iframe>
    ​​​​​​​
    How would you code it yourself ? Imagine, you want to display in the iframe the url that is the final entry in the "your blog url" column in users tbl in mysql db.

    Imagine the tbl looks like this:

         users
    id|your_blog_url
    6|http://myownblog.com

    And since the "http://myownblog.com" is the final entry in the "your_blog_url" column you want to load that in the iframe.

    Whatever sample you provide, make sure it works by checking it in your wamp/xampp before adding your code in this thread.

    Thanks!
    Last edited by UniqueIdeaMan; April 29th, 2017 at 07:58 PM.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2017
    Posts
    307
    Rep Power
    1

    Question


    Ok,

    These asterisks turn up out of the blue when I copy and paste code from my note pad++.

    Here's the original script.
    I shortened it 2 nights ago so you guys don't have to wade through many lines of code. And while shortening it, I made mistakes which you see in my previous code. And so, here's the full script for that particular page.
    config.php contains the db connection details and other files.
    I get no erros but I get nothing visible on the screen. Full blank white page!!!



    Code:
        <html>
        <head>
        <title>
        Home Page
        </title>
        </head>
        <body>
        
        <?php
        include 'config.php';
        
        /*Check if user is logged-in or not by checking if session is set or not. 
        If user is not logged-in then redirect to login page. Else, show user's account homepage.*/
        
        if(!isset($_SESSION["user"])) 
        {
            header("location:login.php");
        }
        else 
        {
        	$user = $_SESSION["user"];
            $sql = "SELECT * FROM users WHERE usernames = '".$user."'";
        	$result = mysqli_query($conn,$sql);
            $numrows = mysqli_num_rows($result);
            if($numrows >1)
        	{	
        		while ($row = mysqli_fetch_assoc($sql))
        		{
        			$db_id = $row["id"];
        			$db_username = $row["usernames"];
        			$db_first_name = $row["first_names"];
        			$db_surname = $row["surnames"];
        			$db_email = $row["emails"];
        			$db_blog_url = $row["blogs_urls"];
            
            		//Welcome user by name.
        			echo "Welcome <b><h2>$db_first_name $db_surname!"?></h2></b>|
        
        			<?php
        			//Display log-out link.
        			echo "<a href='logout.php'>$user Log Out</a>";?>|<br>
            
        			<?php 
        			//Display User's own blog Page in iframe.?>
        			<iframe src="<?php echo $db_blog_url;?>"></iframe>
        			<br>
        
        			<?php 
        			//Display 1st User's blog Page (regardless of who the user is) in iframe.?>
        			<iframe src="<?php echo ".$blogs_urls[0].";?>"></iframe>
        				
        			<?php 
        			//Display All Users' blogs Pages in iframe.?>
        			<iframe src="<?php echo $row['blogs_urls'];?>"></iframe>
        			<?php 
        		}
            }		
        }
        ?>
        
        </body>
        </html>
    Ignore the part where my code is not secure from sql injection. I will deal with that later. In the meanwwhile, concentrating on how to fix this frame thing. I attempted 3 different ways to code the iframe to load a webpage but no luck. I don't get any errors but a complete blank page. Error settings is full set to show error messages (config.php):

    /*
    * ERROR HANDLING
    * ini_set('display_errors', 1);
    * ini_set('display_startup_errors', 1);

    * For All Error, Warning and Notice
    * error_reporting(E_ALL); OR error_reporting(-1);
    * For All Errors
    * error_reporting(E_ERROR);
    * For All Warnings
    * error_reporting(E_WARNING);
    * For All Notice
    * error_reporting(E_NOTICE);
    */
    error_reporting(E_ALL);</pre>

    PS - The url in db is google.com which is supposed to load in iframe.
    Last edited by UniqueIdeaMan; May 1st, 2017 at 09:30 AM.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2017
    Posts
    11
    Rep Power
    0
    A properly secured server is not going to allow you to hijack their sites into your iframe.
  10. #6
  11. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Caro, Michigan
    Posts
    14,810
    Rep Power
    4536
    Learn to make liberal use of echo statements while you're learning. after each IF condition, place an echo status so you can see the flow of your script in the output.

    PHP Code:
    if($numrows 1) {
      echo 
    "Number of rows greater than one, proceeding ... ";
      
    // ... //
    } else {
      echo 
    "Number of rows was less than or equal to one ..";

    I could tell you one error (of many, probably) relating to your fetch() function, but I don't think that'll really help you in your learning process.

    Comments on this post

    • UniqueIdeaMan agrees
    -- Cigars, whiskey and wild, wild women. --
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2017
    Posts
    11
    Rep Power
    0

    Talking


    Originally Posted by Sepodati
    I could tell you one error........., but I don't think that'll really help you in your learning process.

    I could say the same exact thing to you @Sepodati.
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2017
    Posts
    307
    Rep Power
    1

    Question


    Originally Posted by benanamen
    I could say the same exact thing to you @Sepodati.
    Ben,

    Sedopati was indicating the "if ($numrows=1" should be "0").
    Now, weren't you Sedopati ?
  16. #9
  17. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Caro, Michigan
    Posts
    14,810
    Rep Power
    4536
    Originally Posted by benanamen
    I could say the same exact thing to you @Sepodati.
    Well sure. You can say whatever you want. Only one of us would be right, though.
    -- Cigars, whiskey and wild, wild women. --
  18. #10
  19. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2017
    Posts
    11
    Rep Power
    0
    Originally Posted by Sepodati
    Well sure. You can say whatever you want. Only one of us would be right, though.
    I guess I win then. Look at your else response. It is wrong.

    Number of rows was less than or equal to one
    if($numrows > 1)
    That is not less than one, nor is it equal to one. The correct response is GREATER than one.

    Comments on this post

    • UniqueIdeaMan agrees
  20. #11
  21. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2017
    Posts
    11
    Rep Power
    0
    Never mind I read it wrong
  22. #12
  23. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Caro, Michigan
    Posts
    14,810
    Rep Power
    4536
    Originally Posted by benanamen
    Never mind I read it wrong
    Cheers.
    -- Cigars, whiskey and wild, wild women. --
  24. #13
  25. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2017
    Posts
    307
    Rep Power
    1
    Originally Posted by benanamen
    Never mind I read it wrong
    What! You read it wrong ? I just gave you a REP thinking you got it right! SIlly me! I should have read the full context before agreeing with you! Ha! Ha! Nevermind! Now Sepodati is going to be mad with one of us and cross with the other!
    Funny, I'm reading these posts after 2 months!

    Anyway, what kind of a name is Sepodati. Sounds like Sipahi. Are you Indian by any chance ? No ? I got it: Italian ?

    https://www.google.com/search?q=sepa...hrome&ie=UTF-8
    https://www.google.com/search?q=sepa...epahi+or+sepoy

    Are any of these your's:

    https://twitter.com/sedopati
    https://www.facebook.com/search/top/...at&init=public

    Just curious, that's all.
    Last edited by UniqueIdeaMan; July 9th, 2017 at 05:11 PM.
  26. #14
  27. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2017
    Posts
    307
    Rep Power
    1
    Originally Posted by Sepodati
    Well sure. You can say whatever you want. Only one of us would be right, though.
    Why don't you ask Benanaman where you went wrong (according to him) ?

IMN logo majestic logo threadwatch logo seochat tools logo