Get profile by id

0 Steven the awesome · May 29, 2015
So I want to get profile page of the user, by the id in the url, so I can now search with the id in the url and see if the user exsist.


$id = $_GET['id'];

$get_user = mysqli_query($Verbinding, "SELECT * FROM users WHERE id='$id'");
$get = mysqli_fetch_assoc($get_user);


<header>
<nav>
<ul>
<?php

if($get != ""){
echo 'user bestaat';
}else{
header('Location: Profiel.php');
}



echo '<li><a href="Timeline.php">Timeline</a></li>';
echo '<li><a href="Profiel.php">Profiel</a></li>';
echo '<li><a href="Logout.php">Logout</a></li>';

?>
</ul>
   </nav>
</header>





   

Post a Reply

Replies

Oldest  Newest  Rating
0 Anthony Mametsa · May 31, 2015
i think i showed u what you wanted
0 Anthony Mametsa · May 31, 2015
chane $dp_id = $get_u['id'];
0 Steven the awesome · May 31, 2015
Well with this code you can only see if the user exsist, but I don't see the profile of that user.
0 Steven the awesome · June 2, 2015
Whatever I solved it anyway.
0 Anthony Mametsa · May 30, 2015
$get_user = mysql_query("SELECT * FROM usersWHERE id = '$id' LIMIT 1");
  $get_u = mysql_fetch_assoc($get_user);
  $dp_id = $get_u['username'];

echo "$dp_id";


or

go to http://www.w3schools.com/php
0 Scott Adkin · May 30, 2015
You could just check the amount of rows returned by the query using mysql_num_rows(), if it returns 0 then that user doesn't exist.

$id = $_GET['id'];

$get_user = mysqli_query($Verbinding, "SELECT id FROM users WHERE id='$id'");
$rows = mysql_num_rows($get_user);




<header>
<nav>
<ul>
<?php



if($rows == 1){
echo 'user bestaat';
}else{
header('Location: Profiel.php');
}





echo '<li><a href="Timeline.php">Timeline</a></li>';
echo '<li><a href="Profiel.php">Profiel</a></li>';
echo '<li><a href="Logout.php">Logout</a></li>';

?>
</ul>
</nav>
</header>
0 Steven the awesome · May 30, 2015
I think you don't understand what I mean, I can already check if the user exsist or not. But now when the user exsist, I want to see the profile of that user
  • 1

PHP

107,039 followers
About

Server-side, HTML embedded scripting language used to create dynamic Web pages.

Links
Moderators