Page 1 of 1

User ID not detected in iframe

Posted: 07 Feb 2018, 15:11
by JanMolendijk
Dear Admin I have a simple problem the id is not detected in:

Code: Select all

<iframe src="/Comments/user/Profile-E-Mail-Send.php?id=<?php echo $users[id];?>"


Php code:

Code: Select all

<?php 
  
include('../connection.php');

$id = (int) $_GET['id'];

$sql=mysqli_query($conn,"SELECT * FROM `user` WHERE id='" . $id . "' ");
$users=mysqli_fetch_assoc($sql);
?>

Code: Select all

<?php
// connect to the "tests" database
$conn = new mysqli('127.0.0.1', 'comments', '123456', 'comments');
// check connection
if (mysqli_connect_errno()) {
  exit('Connect failed: '. mysqli_connect_error());
}

$id = (int) $_GET['id'];

// SELECT sql query
$sql = "SELECT `id`, `email_privacy` FROM `user`  WHERE email_privacy='Only Members' OR email_privacy='' AND  id='" . $id . "' LIMIT 1 "; 
// perform the query and store the result
$result = $conn->query($sql);
// if the $result contains at least one row
if ($result->num_rows > 0) {
  // output data of each row from $result
  while($row = $result->fetch_assoc()) {
    echo '<iframe src="/Comments/user/Privacy-E-Mail.php" 
width="300" height="300" frameborder="0" scrolling="no" 
align="top" marginwidth="0" marginheight="0" name="email">
</iframe>
<p> '. $row['email_privacy'] ;
  }
}
else {
  echo '<iframe src="/Comments/user/Profile-E-Mail-Send.php?id=<?php echo $users[id];?>" 
width="400" height="400" frameborder="0" scrolling="no" 
align="top" marginwidth="0" marginheight="0" name="email">
</iframe>';
}
$conn->close();
?>

User ID not detected in iframe

Posted: 07 Feb 2018, 16:10
by Admin
Don't add "<?php echo.." into another "echo".
Try this:

Code: Select all

echo '<iframe src="/Comments/user/Profile-E-Mail-Send.php?id='.$users['id'].'" 
width="400" height="400" frameborder="0" scrolling="no" align="top" marginwidth="0" marginheight="0" name="email">
</iframe>';

User ID not detected in iframe

Posted: 07 Feb 2018, 16:43
by JanMolendijk
Thank alot for the support `its working now`