Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

How To Display In iFrame A Url From Mysql ?

php

  • Please log in to reply
2 replies to this topic

#1 uniqueideaman

uniqueideaman

    CC Regular

  • Member
  • PipPipPip
  • 33 posts

Posted 16 March 2017 - 07:38 AM

This is my latest shortened version of the homepage in my reg-login site php.
When you login to your account, your homepage welcomes yuo with your first & surname.
Then it is supposed to show you your bio ($row "bio" in tbl) and show you a url in an iframe ($row "your website" in tbl).
 
Problem is, the iframe is not showing the data (url) that is in the  "your website" in tbl.
I tried escaping, switching to single quote from double but no luck.
What do you think is wrong ?
 
 
<html>
<head>
<title>
$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.php.*/
 
if(!isset($_SESSION["user"])) 
{
    header("location:login.php");
}
else 
{
    $user = $_SESSION["user"];
    $sql = "SELECT * FROM users WHERE Username = '".$user."'";
    $result = $conn->query($sql);
    while($row = $result->fetch_assoc()) 
{
   $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_your_fav_url = $row["Fav_Url"];
    
 
   //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 Bio.   
echo "<br><b>Bio:</b><br>
$db_bio";?><br>
<br>
 
<?php 
//Display User's Fav Url in iFrame.?>
<iframe src='$db_your_fav_url'></iframe>
<?php
}
}
?>
 
</body>
</html>
 
 
The "Bio" column shows no data on page even thopugh the column contains data in the db.
I get error:
 
[16-Mar-2017 15:29:44 UTC] PHP Notice:  Undefined index: Your_Fav_Url in /home/sn/public_html/sn/home.php on line 34
 

  • 0

#2 uniqueideaman

uniqueideaman

    CC Regular

  • Member
  • PipPipPip
  • 33 posts

Posted 17 March 2017 - 05:50 PM

Here is latest update of the code but still it shows not the variable value as the iframe url. Variable calls db row data.
iFrame supposed to open to the url mentioned in the variable. The variable gets the data from the db row: Latest_View.
I get no errors, though!
 
 
<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 = $conn->query($sql);
    while($row = $result->fetch_assoc()) 
{
   $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_latest_view = $row["Latest_View"];
    
 
   //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 Bio.
echo "<br><b>Bio:</b><br>";
echo "$db_bio";?><br>
<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 $db_latest_view;?>"></iframe>
<?php
}
}
?>
 
</body>
</html>
 

  • 0

#3 uniqueideaman

uniqueideaman

    CC Regular

  • Member
  • PipPipPip
  • 33 posts

Posted 19 March 2017 - 03:56 AM

This forum is no good and dead!


  • 0