Jump to content

profile.php issue


ianhaney50
Go to solution Solved by ianhaney50,

Recommended Posts

Hi
 
I just came across one little issue, hopefully is the last one as all the rest is perfect, on my profile.php it seems to be displaying everyones data and not just the data of the user I am logged in as, the coding is below from the profile.php file
 
<?php
ini_set('display_startup_errors',1);
ini_set('display_errors',1);
error_reporting(-1);
?>

<?php 
require_once("functions.php");
require_once("db-const.php");
?>

<?php 
$title = "My Account Profile - The Tax Elephants";

$pgDesc="";

$pgKeywords="";

include ( 'includes/header.php' );
?>
<!--CONTENT-->

<div id="column-whole">
<div class="features">
<?php

if (logged_in() == false) {
redirect_to("login.php");
} else {
if (isset($_GET['id']) && $_GET['id'] != "") {
$id = $_GET['id'];
} else {
$id = $_SESSION['user_id'];
}

$db = mysqli_connect("" , "", "") or die("Check connection parameters!"); 
// Optionally skip select_db and use: mysqli_connect(host,user,pass,dbname)  
mysqli_select_db($db,"") or die(mysqli_error($db));

if (mysqli_connect_error()) {
    die ('Failed to connect to MySQL');
} else {
echo '';
}

## query database
# fetch data from mysql database

$sql = "SELECT
        u.id
        , name
        , email
, address1
, address2
, town
, county
, postcode
, telnumber
, mobnumber
        , model
        , numplate
        , item.description
        , DATE_FORMAT(renewal_date, '%e %M %Y') as datedue
        FROM users u
            INNER JOIN renewal USING (id)
            INNER JOIN item USING (item_id)
ORDER BY u.id, renewal_date;";

$query = mysqli_query($db, $sql) or die (mysqli_error($db));

$prev_id = 0;

//fetch the data from the database 
while ($row = mysqli_fetch_array($query)) { 

// if the vistor id does not equal the vistor id from previous row, 
    // output vistor id, name and email only once
    if($row['id'] != $prev_id)
    {

echo "Name: " . $row ['name'];
echo "<br>";
echo "Email: " . $row ['email'];
echo "<br>";
echo "First line of address: " . $row ['address1'];
echo "<br>";
echo "Second line of address: " . $row ['address2'];
echo "<br>";
echo "Town: " . $row ['town'];
echo "<br>";
echo "County: " . $row ['county'];
echo "<br>";
echo "Postcode: " . $row ['postcode'];
echo "<br>";
echo "Telephone Number: " . $row ['telnumber'];
echo "<br>";
echo "Mobile Number: " . $row ['mobnumber'];
echo "<br>";
echo "Model of car: " . $row ['model'];
echo "<br>";
echo "Car Number Plate: " . $row ['numplate'];
}

// output the reneweal dates
    echo "<br>";
    echo $row ['description'] . " expiry date: " . $row['datedue'] . "\n";

    // set current rows vistor id to previous id
    $prev_id = $row['id'];
}

echo "<br><br>";

echo "<a href='edit-profile.php?id={$_SESSION['user_id']}'>Edit Information</a>";

}

// Free the results  
mysqli_free_result($query);

//close the connection
mysqli_close($db);
?>
</div>
</div>

<!--CONTENT-->

<?php include( 'includes/footer.php' ); ?>

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.